|
|
|
|
|
by Nullabillity
3475 days ago
|
|
And then, to avoid XSS, you'd need to replace that by: <?php foreach($list as $item) { ?>
<li><?= htmlentities($item['name']) ?>
<?php } ?>
Which is, IMO, the main problem with using PHP (or any other from of plain string concatenation) as a templating language. Escaping everything (and security in general) should be the default, not something that you have to opt into at every turn. |
|
Escaping-as-default helps, but people sometimes forget escaping is a function of output context. For example,
is a potential vulnerability if the default escaping mechanism for {bar} is one meant for HTML.