asp 过滤方法,自己常用的。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | Function HTMLEncode(t0) IF Len(t0)< 0 Or IsArray(t0) Then Exit Function t0=Trim(t0) t0=Re(t0,CHR(9),"") '"TAB" t0=Re(t0,CHR(13),"") '回车 t0=Re(t0,CHR(22),"") t0=Re(t0,CHR(38),"&") '“&” t0=Re(t0,CHR(32)," ") '“ ” t0=Re(t0,CHR(34),""") '“"” t0=Re(t0,CHR(37),"%") '“%” t0=Re(t0,CHR(39),"'") '“'” t0=Re(t0,CHR(42),"*") '“*” t0=Re(t0,CHR(43),"+") '“+” t0=Re(t0,CHR(44),",") '“,” t0=Re(t0,CHR(45)&CHR(45),"--") '“--” t0=Re(t0,CHR(92),"\") '“\” t0=Re(t0,CHR(40),"(") '“(” t0=Re(t0,CHR(41),")") '“)” t0=Re(t0,CHR(60),"<") '“<” t0=Re(t0,CHR(62),">") '“>” t0=Re(t0,CHR(123),"{") '“{” t0=Re(t0,CHR(125),"}") '“}” t0=Re(t0,CHR(59),";") '“;” t0=Re(t0,CHR(10)&CHR(10),CHR(10))'把换行替换掉 t0=Re(t0,CHR(10),"< br >")'换行 t0=ReplaceText(t0,"([&#])([a-z0-9]*);","$1$2;") IF lyq_BadText<>"" Then t0=ReplaceText(t0,"("&lyq_BadText&")",String(Len("&$1&"),"*")) '过滤片假名(日文字符)[\u30A0-\u30FF] IF Is_sql Then t0=Escape(t0) t0=ReplaceText(t0,"%u30([A-F][0-F])","0$1;") t0=Unescape(t0) End IF HTMLEncode=t0 End Function |
1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | < pre class="brush:html">Function Re(t0,t1,t2) IF Isnull(t2) Then t2="" Re=Replace(t0,t1,t2) End Function </ pre > < pre class="brush:html">Function ReplaceText(t0,t1,t2) Set regEx=New RegExp regEx.Pattern=t1 regEx.IgnoreCase=True regEx.Global=True ReplaceText=regEx.Replace(""&t0&"",""&t2&"") Set regEx=nothing End Function </ pre > |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 单线程的Redis速度为什么快?
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 展开说说关于C#中ORM框架的用法!
· SQL Server 2025 AI相关能力初探
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库