麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 編程 > ASP > 正文

asp中常用的字符串安全處理函數(shù)集合(過濾特殊字

2024-05-04 11:08:25
字體:
供稿:網(wǎng)友
在asp編寫中,我們需要注意特殊字符串的處理,防止被黑客利用。使用asp的朋友一定要參考下。
 
 
 
復(fù)制代碼代碼如下:

'===================================== 
'轉(zhuǎn)換內(nèi)容,防止意外 
'===================================== 
Function Content_Encode(ByVal t0) 
IF IsNull(t0) Or Len(t0)=0 Then 
Content_Encode="" 
Else 
Content_Encode=Replace(t0,"<","<") 
Content_Encode=Replace(Content_Encode,">",">") 
End IF 
End Function 

'===================================== 
'反轉(zhuǎn)換內(nèi)容 
'===================================== 
Function Content_Decode(ByVal t0) 
IF IsNull(t0) Or Len(t0)=0 Then 
Content_Decode="" 
Else 
Content_Decode=Replace(t0,"<","<") 
Content_Decode=Replace(Content_Decode,">",">") 
End IF 
End Function 

'===================================== 
'過濾字符 
'===================================== 
Function FilterText(ByVal t0,ByVal t1) 
IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterText="":Exit Function 
t0=Trim(t0) 
Select Case t1 
Case "1" 
t0=Replace(t0,Chr(32)," ") 
t0=Replace(t0,Chr(13),"") 
t0=Replace(t0,Chr(10)&Chr(10),"<br>") 
t0=Replace(t0,Chr(10),"<br>") 
Case "2" 
t0=Replace(t0,Chr(8),"")'回格 
t0=Replace(t0,Chr(9),"")'tab(水平制表符) 
t0=Replace(t0,Chr(10),"")'換行 
t0=Replace(t0,Chr(11),"")'tab(垂直制表符) 
t0=Replace(t0,Chr(12),"")'換頁 
t0=Replace(t0,Chr(13),"")'回車 chr(13)&chr(10) 回車和換行的組合 
t0=Replace(t0,Chr(22),"") 
t0=Replace(t0,Chr(32),"")'空格 SPACE 
t0=Replace(t0,Chr(33),"")'! 
t0=Replace(t0,Chr(34),"")'" 
t0=Replace(t0,Chr(35),"")'# 
t0=Replace(t0,Chr(36),"")'$ 
t0=Replace(t0,Chr(37),"")'% 
t0=Replace(t0,Chr(38),"")'& 
t0=Replace(t0,Chr(39),"")'' 
t0=Replace(t0,Chr(40),"")'( 
t0=Replace(t0,Chr(41),"")') 
t0=Replace(t0,Chr(42),"")'* 
t0=Replace(t0,Chr(43),"")'+ 
t0=Replace(t0,Chr(44),"")', 
t0=Replace(t0,Chr(45),"")'- 
t0=Replace(t0,Chr(46),"")'. 
t0=Replace(t0,Chr(47),"")'/ 
t0=Replace(t0,Chr(58),"")': 
t0=Replace(t0,Chr(59),"")'; 
t0=Replace(t0,Chr(60),"")'< 
t0=Replace(t0,Chr(61),"")'= 
t0=Replace(t0,Chr(62),"")'> 
t0=Replace(t0,Chr(63),"")'? 
t0=Replace(t0,Chr(64),"")'@ 
t0=Replace(t0,Chr(91),"")'/ 
t0=Replace(t0,Chr(92),"")'/ 
t0=Replace(t0,Chr(93),"")'] 
t0=Replace(t0,Chr(94),"")'^ 
t0=Replace(t0,Chr(95),"")'_ 
t0=Replace(t0,Chr(96),"")'` 
t0=Replace(t0,Chr(123),"")'{ 
t0=Replace(t0,Chr(124),"")'| 
t0=Replace(t0,Chr(125),"")'} 
t0=Replace(t0,Chr(126),"")'~ 
Case Else 
t0=Replace(t0, "&", "&") 
t0=Replace(t0, "'", "'") 
t0=Replace(t0, """", """) 
t0=Replace(t0, "<", "<") 
t0=Replace(t0, ">", ">") 
End Select 
IF Instr(Lcase(t0),"expression")>0 Then 
t0=Replace(t0,"expression","e­xpression", 1, -1, 0) 
End If 
FilterText=t0 
End Function 

'===================================== 
'過濾常見字符及Html 
'===================================== 
Function FilterHtml(ByVal t0) 
IF Len(t0)=0 Or IsNull(t0) Or IsArray(t0) Then FilterHtml="":Exit Function 
IF Len(Sdcms_Badhtml)>0 Then t0=ReplaceText(t0,"<(//|)("&Sdcms_Badhtml&")", "<$1$2") 
IF Len(Sdcms_BadEvent)>0 Then t0=ReplaceText(t0,"<(.[^>]*)("&Sdcms_BadEvent&")", "<$1$2") 
t0=FilterText(t0,0) 
FilterHtml=t0 
End Function 

Function GotTopic(ByVal t0,ByVal t1) 
IF Len(t0)=0 Or IsNull(t0) Then 
GotTopic="" 
Exit Function 
End IF 
Dim l,t,c, i 
t0=Replace(Replace(Replace(Replace(t0," "," "),""",chr(34)),">",">"),"<","<") 
l=Len(t0) 
t=0 
For I=1 To l 
c=Abs(Asc(Mid(t0,i,1))) 
IF c>255 Then t=t+2 Else t=t+1 
IF t>=t1 Then 
gotTopic=Left(t0,I)&"…" 
Exit For 
Else 
GotTopic=t0 
End IF 
Next 
GotTopic=Replace(Replace(Replace(Replace(GotTopic," "," "),chr(34),"""),">",">"),"<","<") 
End Function 

Function UrlDecode(ByVal t0) 
Dim t1,t2,t3,i,t4,t5,t6 
t1="" 
t2=False 
t3="" 
For I=1 To Len(t0) 
t4=Mid(t0,I,1) 
IF t4="+" Then 
t1=t1&" " 
ElseIF t4="%" Then 
t5=Mid(t0,i+1,2) 
t6=Cint("&H" & t5) 
IF t2 Then 
t2=False 
t1=t1&Chr(Cint("&H"&t3&t5)) 
Else 
IF Abs(t6)<=127 then 
t1=t1&Chr(t6) 
Else 
t2=True 
t3=t5 
End IF 
End IF 
I=I+2 
Else 
t1=t1&t4 
End IF 
Next 
UrlDecode=t1 
End Function 

Function CutStr(byVal t0,byVal t1) 
Dim l,t,c,i 
IF IsNull(t0) Then CutStr="":Exit Function 
l=Len(t0) 
t1=Int(t1) 
t=0 
For I=1 To l 
c=Asc(Mid(t0,I,1)) 
IF c<0 Or c>255 Then t=t+2 Else t=t+1 
IF t>=t1 Then 
CutStr=Left(t0,I)&"..." 
Exit For 
Else 
CutStr=t0 
End IF 
Next 
End Function 

Function CloseHtml(ByVal t0) 
Dim t1,I,t2,t3,Regs,Matches,J,Match 
Set Regs=New RegExp 
Regs.IgnoreCase=True 
Regs.Global=True 
t1=Array("p","div","span","table","ul","font","b","u","i","h1","h2","h3","h4","h5","h6") 
For I=0 To UBound(t1) 
t2=0 
t3=0 
Regs.Pattern="/<"&t1(I)&"( [^/</>]+|)/>" 
Set Matches=Regs.Execute(t0) 
For Each Match In Matches 
t2=t2+1 
Next 
Regs.Pattern="/</"&t1(I)&"/>" 
Set Matches=Regs.Execute(t0) 
For Each Match In Matches 
t3=t3+1 
Next 
For j=1 To t2-t3 
t0=t0+"</"&t1(I)&">" 
Next 
Next 
CloseHtml=t0 
End Function

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 一区二区网 | 爱操影视| 精品在线免费播放 | 国产亚洲精品久久久久久久久 | 成人一级片毛片 | 国产jjizz一区二区三区视频 | 午夜视频在线免费播放 | 国产成年人视频 | av性色全交蜜桃成熟时 | 国产精品视频二区不卡 | 精品国产一区二区三区成人影院 | 久久精品探花 | 黄色片网站在线免费观看 | 一级片久久免费 | 久久艳片 | 久久久中文 | 中国产一级毛片 | 国产第一页精品 | 亚洲精品一区中文字幕 | 亚洲嫩草av | 成人免费网站在线观看视频 | 操嫩草| 国产免费传媒av片在线 | www.91sao| 国产精品久久久久久久久久久久久久久久 | 72pao成人国产永久免费视频 | 精品久久久久久亚洲精品 | 国产影视 | 成人福利在线播放 | 毛片视频网址 | 99欧美视频 | 一区播放 | 曰韩黄色片 | 久久精品亚洲一区二区 | 国产亚洲精品久久久久久久久久 | 欧美一级做性受免费大片免费 | 天堂亚洲一区 | 国产亚洲网 | 轻点插视频 | 二级大黄大片高清在线视频 | www.99tv|