
PHP 安全測驗為我提供了 GetHTMLValueString 的嚴重反射 XSS 警告,我該如何解決?
uj5u.com熱心網友回復:
嘗試將值轉換為HTML 物體
<?php $depo_gin = '<a>1</a>'; ?>
<td>...</td><td><?php echo htmlentities( GetHTMLValueString($depo_gin) ); ?></td>
或者
<?php $depo_gin = '<a>1</a>'; ?>
<td>...</td><td><?php echo htmlspecialchars( GetHTMLValueString($depo_gin) ); ?></td>
結果為 HTML:
<td>...</td><td><a>1</a></td>
檔案:
https://www.php.net/manual/en/function.htmlentities.php
https://www.php.net/manual/en/function.htmlspecialchars.php
如果您只需要來自 html 內容的值
嘗試使用功能 strip_tags
<?php
var_dump(
strip_tags('<a>1</a>')
); # result: 1
https://www.php.net/manual/en/function.strip-tags
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/358788.html
上一篇:IIS上未實作HttpTRACE
