cvs: phpweb / search.php
| From: | jim winstead | Date: | Mon, 25 Mar 2002 19:20:24 +0000 |
| Subject: | cvs: phpweb / search.php | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-9242@lists.php.net to get a copy of this message | ||
jimw Mon Mar 25 14:20:24 2002 EDT
Modified files:
/phpweb search.php
Log:
protect against cross-site scripting attack via "base" parameter
Index: phpweb/search.php
diff -u phpweb/search.php:1.26 phpweb/search.php:1.27
--- phpweb/search.php:1.26 Thu Feb 21 15:48:47 2002
+++ phpweb/search.php Mon Mar 25 14:20:23 2002
@@ -10,6 +10,8 @@
/* we don't want magic slashes in pattern or prevsearch */
if (isset($pattern) && get_magic_quotes_gpc())
$pattern = stripslashes($pattern);
+if (isset($base) && get_magic_quotes_gpc())
+ $base = stripslashes($base);
if (isset($prevsearch) && get_magic_quotes_gpc())
$prevsearch = stripslashes($prevsearch);
@@ -143,11 +145,7 @@
}
}
- if ($base == "-") {
- $sourceurl = $PHP_SELF;
- } else {
- $sourceurl = $base.$PHP_SELF;
- }
+ $sourceurl = htmlentities($base == '-' ? $PHP_SELF : $base.$PHP_SELF);
if ($pattern == "") {
echo "<b>Error:</b> No search words specified.<br><br>";
@@ -191,7 +189,7 @@
$lastdisplayed = $result[4];
$page = $result[5];
$pages = $result[6];
- $baseurl = $PHP_SELF."?pattern=$words&show=$show&base=$base";
+ $baseurl = htmlentities($PHP_SELF."?pattern=$words&show=$show&base=$base");
echo "$matches documents match your search for
'<b>",htmlspecialchars($pattern),"</b>' in the
$where:<br><br>\n";
echo "Click here for a <a href=\"$sourceurl\">New
Search</a><br><br>\n";