Avoid XSS vulnerability on the search engine

Raised by https://www.xssposed.org/incidents/69566/
Need to escape the user provided query before displaying it back
This commit is contained in:
Daniel Veillard 2015-07-03 20:47:08 +08:00
parent 2854079496
commit d51876bc8e

View File

@ -13,7 +13,7 @@
<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 $query?>"/>
<input name="query" type="text" size="50" value="<?php echo htmlspecialchars($query, ENT_QUOTES, 'UTF-8')?>"/>
<select name="scope">
<option value="any">Search All</option>
<option value="API" <?php if ($scope == 'API') print "selected='selected'"?>>Only the APIs</option>