你只在输出上运行htmlspecialchars(),还有还有其他功能吗? [英] Do you only run htmlspecialchars() on output or is there other functionality you also do?
问题描述
输出用户输入时,您只使用 htmlspecialchars()
还是运行的函数/动作/方法?我正在寻找一些也将处理XSS的东西。
When outputting user input, do you only use htmlspecialchars()
or are there are functions/actions/methods you also run? I'm looking for something that will also deal with XSS.
我想知道我是否应该编写一个函数来转义输出上的用户输入,或者只是使用用htmlspecialchars()
。我正在寻找通用的案例,而不是可以单独处理的具体案例。
I'm wondering if I should write a function that escapes user input on output or just use htmlspecialchars()
. I'm looking for the generic cases, not the specific cases that can be dealt with individually.
推荐答案
我通常使用<
I usually use
htmlspecialchars($var, ENT_QUOTES)
输入字段。我创建了一个这样做的方法,因为我使用它很多,它使代码更短,更易读。
on input fields. I created a method that does this because i use that a lot and it makes the code shorter and more readable.
这篇关于你只在输出上运行htmlspecialchars(),还有还有其他功能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!