在经典 asp 中清理输入的好方法
我必须更新工作中的旧项目。 尽管我熟悉 php 脚本,但我没有任何经典 asp 的经验。
- 有什么我应该使用的功能吗?
- 能给我提供一些基本的保护功能吗?
- asp中有类似参数化查询的东西吗?
谢谢!
I have to update old projects at work. I do not have any experience with classic asp, although i'm familiar with php scripting.
- Are there any functions I should use?
- Can you provide me with a good function for some basic protection?
- Is there something like a parameterized query in asp?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
是的,您可以在经典 ASP(更准确地说,经典 ADO)中使用参数化查询。
这是链接。
至于编码输出,我可能会想为最新的 Microsoft Anti-XSS 库创建一个包装器,并使用 Server.CreateObject 调用它。 我远不是这类事情的专家,因为我在 .Net 上花费了更多时间,所以我认为这会起作用。
Server.HTMLEncode 确实不够好,因为它只将一些编码字符列入黑名单。 Anti-XSS 库要好得多,因为它将可接受的内容列入白名单。
Yes you can use parametrized queries in classic ASP (more accurately, classic ADO).
Here is a link.
As for encoding output, I might be tempted to create a wrapper for the latest Microsoft Anti-XSS library and call it with Server.CreateObject. I am far from an expert on this kind of thing as I spend much more time in .Net, so I only think this would work.
Server.HTMLEncode is really not good enough, as it only blacklists a few encoding characters. The Anti-XSS library is much better as it whitelists what is acceptable.
始终使用 Server.HTMLEncode 来清理用户输入。
例如,如果您要从表单文本框设置变量:
firstName = Server.HTMLEncode(trim(request.form("firstname")))
Always use Server.HTMLEncode to sanitize user input.
For example, if you're setting a variable from a form text box:
firstName = Server.HTMLEncode(trim(request.form("firstname")))
注意 SQL 注入。 不要将用户输入连接到 SQL 字符串然后执行它。 相反,始终使用参数化查询。
Watch out for SQL injection. Do not concatenate user input to a SQL string and then execute it. Instead, always used parameterized queries.
有很多以 Is 开头的函数,例如
IsNumber
、IsArray
等,您可能会感兴趣。 另外,如果您需要一个整数,则可以使用 CLng(Request("blabla")) 来获取它,因此如果它不是整数,则 CLng 函数将引发错误。There is a bunch of functions starting with Is, such as
IsNumber
,IsArray
etcetera, that might be of interest. Also if you're expecting a integer, you could useCLng(Request("blabla"))
to get it, thus if it's not a integer the CLng function will raise an error.一种方法可能是在
header.asp
文件中添加一个检查,该文件循环访问Request
对象以查找不适当的字符。 例如:One way to do it might be to add a check in a
header.asp
file that iterates through theRequest
object looking for inappropriate characters. For example: