复制代码 代码如下:
function HTMLEncode(fString)
if not isnull(fString) then
fString = replace(fString, ">", "gt;")
fString = replace(fString, "", "lt;")
fString = Replace(fString, CHR(32), "nbsp;")
fString = Replace(fString, CHR(9), "nbsp;")
fString = Replace(fString, CHR(34), "quot;")
fString = Replace(fString, CHR(39), "#39;")
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10) CHR(10), "/P>P> ")
fString = Replace(fString, CHR(10), "BR> ")
HTMLEncode = fString
end if
end function
Function Safe(str)'该函数用来判断传递过来的变量是否包含特殊字符,没有返回TRUE
Dim s_BadStr, n, i
s_BadStr = "' >?%,;:()`~!@#$^*{}[]|\/+-="Chr(34)Chr(9)Chr(32)
n = Len(s_BadStr)
Safe = True
For i = 1 To n
If Instr(str, Mid(s_BadStr, i, 1)) > 0 Then
Safe = False
Exit Function
End If
Next
End Function