1

I'm reading the following article on how to use htmlspecialchars() properly:

http://blog.astrumfutura.com/2012/03/a-hitchhikers-guide-to-cross-site-scripting-xss-in-php-part-1-how-not-to-use-htmlspecialchars-for-output-escaping/

In the article the following syntax is used as an example:

<?php header('Content-Type: text/html; charset=UTF-8'); ?>
<!DOCTYPE html>
<?php
$input = <<<INPUT
' onmouseover='alert(/Meow!/);
INPUT;
/**
 * NOTE: This is equivalent to using htmlspecialchars($input, ENT_COMPAT)
 */
$output = htmlspecialchars($input);
?>
<html>
<head>
<title>Single Quoted Attribute</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
    <div>
        <span title='<?php echo $output ?>'>
            What's that latin placeholder text again?
        </span>
    </div>
</body>
</html>

I am still pretty much a noob obviously and have never seen the <<

Just wondering if anyone could briefly explain what this syntax is meant to do. I'm trying to understand the article, but I sort of need to understand what this code is doing first.

Joe
  • 1,117
  • 1
  • 8
  • 13

0 Answers0