簡體   English   中英

PHP 安全測試為我提供了 GetHTMLValueString 的關鍵反射 XSS 警告,我該如何解決?

[英]PHP Security test gives me critical Reflected XSS warning for GetHTMLValueString, how can i fix?

在此處輸入圖片說明

PHP 安全測試為我提供了 GetHTMLValueString 的關鍵反射 XSS 警告,我該如何解決?

嘗試將值轉換為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>&lt;a&gt;1&lt;/a&gt;</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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM