Hallo!
Bei den Kommentaren zur PHP-Dokumentation von htmlentities() steht als erstes
„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>
?>
Jetzt stellt sich mir die Frage wie ich das verhindern kann.
Wie kodiere ich einen String so, dass er als URL (href) in einem Link nicht verstümmelt wird aber auch kein Schaden angerichtet werden kann?
Vielen Dank!