- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
<分区>
Possible Duplicate:
What are the best practices for avoiding xss attacks in a PHP site
What are the common defenses against XSS?
我正在尝试使我编写的 PHP 应用程序安全,但对转义输出有疑问。一旦我了解到这样做可以防止 SQL 注入(inject),我就转而使用带有 PDO 的准备好的语句,而且似乎另一种主要的攻击类型是 XSS。我像这样为我的页面构建输出(假设变量中包含来自数据库的数据):
$output = '';
$output .= '
<div style="float: left; width: 800px;">
<span>Name:</span><span> ' . $name . '</span>
<span>Address:</span><span>' . $addr . '</span>
<span>Time:</span><span>' . time() . '</span>
</div>';
$output .='[lots more html]';
所以,我的问题是,我是否应该在输出数据库中的每条数据周围使用 htmlentities()
(一个典型的页面有几十个,有的可能是数百个来自正在输出的数据库的变量)?
我找到了一些提到这个问题的帖子,但没有一个能完全解决它。 我需要一个函数来输出内容,以 htmlentities() 的方式转换所有特殊字符,但保留所有 html 标签。 我尝试了很多不同的方法,但正
现在我正在尝试通过 htmlentities() 函数运行数组中每一行(“记录”/对象)的一个属性/“列”。因为只有该属性/列包含将在 DOM html 中输出的字符串。 但是,我正在获取所需的行并将
我正在尝试将单引号 (') 简单转换为 html 实体 (') 但无法弄清楚为什么这不起作用. $test = "Bob's House"; echo htmlentities($test,ENT_Q
我正在尝试将单引号 (') 简单转换为 html 实体 (') 但无法弄清楚为什么这不起作用. $test = "Bob's House"; echo htmlentities($test,ENT_Q
我有一个 div id="ultimativegodemperorofalldivs"它包含一些文本,例如“such a cool & sexy div” 当我用 JS 提取 InnerHTML 时,
我正在从数据库中提取数据(原始): long's streetWe’d " tree 根据我的理解,为了将其输出到 html 页面,我应该需要将其包装在 htmlEntities 中。 但是当我包装
我正在使用 htmlentities() 将 Ç 和 ® 等字符转换为其字符代码。我正在从 MYSQL 数据库中获取文本。 while($row = mysql_fetch_array($array,
我正在尝试做一些 htmlentities。但是,由于超链接被转换为 html 代码,现在超链接被破坏了,出于一些愚蠢的原因,大学为我们提供了相同的服务器密码。 去年我几乎失败了,因为有人进入我的服务
我正在 PDO 类的帮助下使用 PHP 和 MySQL 创建一个论坛。我刚刚开始编写论坛代码并遇到了一个问题。 我做的是那个 $post_body = htmlentities($_POST['pos
我们有一个网络应用程序,我们允许用户在文本区域中输入他们自己的 html。我们将该数据保存到我们的数据库中。 当我们将html数据加载到文本区域时,当然是在将html数据扔到文本区域之前使用htmle
我只想将未编码的字符转换为 html 实体,而不影响已经存在的实体。我有一个字符串,其中包含以前编码的实体,例如: gaIUSHIUGhj>‐ hjb×jkn.jhuh>hh
当然,这个问题之前已经被问过,并且已经在寻找解决方案,但到目前为止都没有奏效。我想通过使用 htmlentities 或 htmlspecialchars 将 TM 符号和符号更改为它们的 html
我在问自己使用 php 函数 htmlentities() 来对抗 XSS 攻击的安全性,也许还有相关函数,如 htmlspecialchars。 非常感谢:) 最佳答案 您将需要明确指定正确的编码(
我正在尝试显示字符 html 实体 echo htmlentities(htmlentities("&")); //outputs & echo htmlentities(htmlentiti
我们用什么条件来决定何时设置双重编码是真还是假?我们可以使用什么 php 设置变量来决定它? 对于俄语字符,它应该使用双重编码 true 然后它会显示字符。但是如果 double encoded 为
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: PHP htmlentities() on input before DB insert, instead
我正在使用 htmlentites()用安全的 html 替换字符,即 PHP,因为我希望能够显示 PHP 示例。我遇到的问题是所有标签都被替换了(例如:、 等)。我知道我可以编写自定义 htment
我有一个 .NET MVC 页面,其中包含每个项目的列表 rel 中的编码描述.我希望能够搜索带有 rel 的所有项目包含我的搜索查询。 其中一个字段的值为 htmlentities rel='D&
对于像áéí这样的特殊字符,我可以调用htmlentities(): $mycaption = htmlentities($mycaption, ENT_QUOTES); 获取对应的html实体: &
以下代码输出一个空字符串。原因是 $text 中的“ó”,但为什么呢?那么utf-8编码的是什么字符呢? 使用iso-8859-1的时候问题解决了,但是我需要使用utf-8,我做错了什么?
我是一名优秀的程序员,十分优秀!