php 没有好的逃逸
我有一个像这样的脚本:
document.getElementById('debugLayer').innerHTML = '<?php foreach (self::$errorLogs as $item) { echo htmlentities ($item, ENT_QUOTES).'<hr />'; } ?>';
其中 $errorLogs 是列表数组。但它一定没有正确转义,因为 Firefox 对此说:
Error: malformed Unicode character escape sequence
Source File: X
Line: 553, Column: 63
Source Code:
document.getElementById('debugLayerDIVcontent_10').innerHTML = '<span style="background-color:yellow;"><i>Missing argument 3 for Upload::getDamagesStatisticsByUserID(), called in action_index.php on line 149 and defined</i></span>, in <span style="background-color:#40FF40;"><b>Upload.php</b></span> at <i><span style="background-color:red; color:white;">256</span></i> [<b>2</b>]<hr /><span style="background-color:yellow;"><i>Undefined variable: join</i></span>, in <span style="background-color:#40FF40;"><b>Upload.php</b></span> at <i><span style="background-color:red; color:white;">266</span></i> [<b>8</b>]<hr />';
有什么问题吗?
I have a script like this:
document.getElementById('debugLayer').innerHTML = '<?php foreach (self::$errorLogs as $item) { echo htmlentities ($item, ENT_QUOTES).'<hr />'; } ?>';
where $errorLogs is an array of list. But it must have not escape correctly, since firefox say to this:
Error: malformed Unicode character escape sequence
Source File: X
Line: 553, Column: 63
Source Code:
document.getElementById('debugLayerDIVcontent_10').innerHTML = '<span style="background-color:yellow;"><i>Missing argument 3 for Upload::getDamagesStatisticsByUserID(), called in action_index.php on line 149 and defined</i></span>, in <span style="background-color:#40FF40;"><b>Upload.php</b></span> at <i><span style="background-color:red; color:white;">256</span></i> [<b>2</b>]<hr /><span style="background-color:yellow;"><i>Undefined variable: join</i></span>, in <span style="background-color:#40FF40;"><b>Upload.php</b></span> at <i><span style="background-color:red; color:white;">266</span></i> [<b>8</b>]<hr />';
what can be wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
htmlentities()
接受第三个参数来定义使用的字符集。默认是Latin1,使用UTF-8时将其设置为UTF-8htmlentities()
accepts a 3rd argument to define the used charset. The default is Latin1, set it to UTF-8 when you're using UTF-8