]> xenbits.xensource.com Git - libvirt.git/commitdiff
better patch for the XSS search issue
authorDaniel Veillard <veillard@redhat.com>
Fri, 3 Jul 2015 13:04:24 +0000 (21:04 +0800)
committerDaniel Veillard <veillard@redhat.com>
Fri, 3 Jul 2015 13:04:24 +0000 (21:04 +0800)
Since the query string could be output when displaying the results too

docs/search.php.code.in

index 84f87591d5b1baa5856d56eb71f9cc9b09517351..c7511c3782553ba3082a17c2e3e0ded4e6fc8566 100644 (file)
@@ -9,11 +9,12 @@
     $scope = ltrim ($scope);
     if ($scope == "")
         $scope = "any";
+    $querystr = htmlspecialchars($query, ENT_QUOTES, 'UTF-8');
 ?>
 
 <form action="<?php echo $_SERVER['PHP_SELF'], "?query=", rawurlencode($query) ?>"
       enctype="application/x-www-form-urlencoded" method="get">
-  <input name="query" type="text" size="50" value="<?php echo htmlspecialchars($query, ENT_QUOTES, 'UTF-8')?>"/>
+  <input name="query" type="text" size="50" value="<?php echo $querystr ?>"/>
   <select name="scope">
     <option value="any">Search All</option>
     <option value="API" <?php if ($scope == 'API') print "selected='selected'"?>>Only the APIs</option>
            }
            mysql_close($link);
            $nb = count($results);
-           echo "<h3 align='center'>Found $nb results for query $query</h3>\n";
+           echo "<h3 align='center'>Found $nb results for query $querystr</h3>\n";
            usort($results, "resSort");
 
             if ($nb > 0) {