Skip to content

Commit

Permalink
Add parameter sanitization.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbuchbinder committed Dec 4, 2014
1 parent f811f95 commit c32c4f0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions help.php
Expand Up @@ -30,6 +30,13 @@
$parts = explode ( '/', $_SERVER['PATH_INFO'] );
$ui = $parts[1];
$locale = !empty($parts[2]) ? $parts[2] : "en_US";

// Check for sanitized parameters
if (!preg_match("/^[[:alpha:]]+$/", $ui) || !preg_match("/^[[:alpha:]_]+$/", $locale)) {
print "Hack attempt.\n";
die();
}

$path = str_replace ( $parts[0].'/'.$parts[1].'/'.$parts[2], '', $_SERVER['PATH_INFO'] );
// Strip leading slash if it exists ...
if ( substr( $path, 0, 1 ) == '/' ) {
Expand Down

0 comments on commit c32c4f0

Please sign in to comment.