在ASP经典开发中,处理用户输入时有一个常见的模式:首先检查输入长度,如果不为空,则从表单中获取whoto和action参数,并设置session变量。然后,对用户输入中的单引号和双引号进行转义处理,防止SQL注入或脚本注入。最后,使用application.lock来确保线程安全。代码示例如下:
if len(usersays)<>0 then
session("whoto")=request.form("whoto")
session("action")=request.form("action")
if instr(usersays,chr(39))>0 then
usersays=replace(usersays,chr(39),"\"&chr(39))
end if
if instr(usersays,chr(34))>0 then
usersays=replace(usersays,chr(34),"\"&chr(34))
end if
application.lock
[1]