note 104114 added to function.htmlentities
| From: | portalpress dot org at gmail dot com | Date: | Tue, 24 May 2011 13:00:37 +0000 |
| Subject: | note 104114 added to function.htmlentities | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-179997@lists.php.net to get a copy of this message | ||
In addition to Sijmen Ruwhof 13-Sep-2010 07:18 about Cross Site Scripting (XSS) vulnerabilities.
Just use :
function XSShtmlentities($string) {
$XSSarray=array(
" " => " ",
"!" => "!",
"%" => "%",
"(" => "(",
")" => ")",
"*" => "*",
"+" => "+",
"," => ",",
"-" => "-",
"." => ".",
":" => ":",
"=" => "=",
"?" => "?",
"@" => "@",
"{" => "{",
"|" => "|",
"}" => "}",
"~" => "~");
return(strtr(htmlentities($string,ENT_QUOTES),$XSSarray));
}
The array is a bit over the top, but surely XSS-safe.
----
Server IP: 69.147.83.197
Probable Submitter: 109.34.60.179
----
Manual Page -- http://www.php.net/manual/en/function.htmlentities.php
Edit -- https://master.php.net/note/edit/104114
Del: integrated -- https://master.php.net/note/delete/104114/integrated
Del: useless -- https://master.php.net/note/delete/104114/useless
Del: bad code -- https://master.php.net/note/delete/104114/bad+code
Del: spam -- https://master.php.net/note/delete/104114/spam
Del: non-english -- https://master.php.net/note/delete/104114/non-english
Del: in docs -- https://master.php.net/note/delete/104114/in+docs
Del: other reasons-- https://master.php.net/note/delete/104114
Reject -- https://master.php.net/note/reject/104114
Search -- https://master.php.net/manage/user-notes.php