0 Members and 1 Guest are viewing this topic.
<?phpif(isset($_POST['go'])){ echo htmlspecialchars($_POST['text']);}?>
a common confusion among beginner is that what is the difference between htmlentities() and htmlspecialchars() really, because the manual examples are converting angular brackets for both.well, htmlentities() will ALSO look for other language characters in the string e.g German, French or Italian etc. So if you think your attacker can use some foreign language characters for a XSS attack in URL etc then use htmlentities() instead of htmlspecialchars().I hope it helps, Haroon Ahmad
An important note below about using this function to secure your application against Cross Site Scripting (XSS) vulnerabilities.When printing user input in an attribute of an HTML tag, the default configuration of htmlEntities() doesn't protect you against XSS, when using single quotes to define the border of the tag's attribute-value. XSS is then possible by injecting a single quote:<?php$_GET['a'] = "#000' onload='alert(document.cookie)";?>XSS possible (insecure):<?php$href = htmlEntities($_GET['a']);print "<body bgcolor='$href'>"; # results in: <body bgcolor='#000' onload='alert(document.cookie)'>?>Use the 'ENT_QUOTES' quote style option, to ensure no XSS is possible and your application is secure:<?php$href = htmlEntities($_GET['a'], ENT_QUOTES);print "<body bgcolor='$href'>"; # results in: <body bgcolor='#000' onload='alert(document.cookie)'>?>The 'ENT_QUOTES' option doesn't protect you against javascript evaluation in certain tag's attributes, like the 'href' attribute of the 'a' tag. When clicked on the link below, the given JavaScript will get executed:<?php$_GET['a'] = 'javascript:alert(document.cookie)';$href = htmlEntities($_GET['a'], ENT_QUOTES);print "<a href='$href'>link</a>"; # results in: <a href='javascript:alert(document.cookie)'>link</a>?>
ok and what is the conclusion, when use PDO and htmlspecialchars, my system is 100% protected ? , i mean how to make a xss when this thing use? Sorry for my bad English
'100% protected'
15:04 @Phage : I'm bored of Python
Saying this statement anywhere, at anytime, about anything, is pure illusion