婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > asp中常用的字符串安全處理函數集合(過濾特殊字符等)

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

熱門標簽:濟源電銷外呼系統線路 石家莊慧營銷外呼系統 創意電話機器人 外呼線路批發 地圖標注陽江 梧州市地圖標注 武穴地圖標注 java外呼系統是什么 世界地圖標注了哪些城市

我們在注冊的時候經常需要判斷客戶輸入的內容是否合法,或者在頁面傳遞參數的時候要判斷,是否有客戶惡意添加參數進行SQL注入等,這就需要1個函數去判斷檢測。

' ============================================
' 判斷是否安全字符串,在注冊登錄等特殊字段中使用
' ============================================
Function IsSafeStr(str)
 Dim s_BadStr, n, i
 s_BadStr = "'  >?%,;:()`~!@#$^*{}[]|+-="  Chr(34)  Chr(9)  Chr(32)
 n = Len(s_BadStr)
 IsSafeStr = True
 For i = 1 To n
  If Instr(str, Mid(s_BadStr, i, 1)) > 0 Then
   IsSafeStr = False
   Exit Function
  End If
 Next
End Function

大家可以自行添加BadStr字符串里面的字符,增加你想要過濾的字符即可。

下面是其他網友的補充

'===================================== 
'轉換內容,防止意外 
'===================================== 
Function Content_Encode(ByVal t0) 
IF IsNull(t0) Or Len(t0)=0 Then 
Content_Encode="" 
Else 
Content_Encode=Replace(t0,"","lt;") 
Content_Encode=Replace(Content_Encode,">","gt;") 
End IF 
End Function 

'===================================== 
'反轉換內容 
'===================================== 
Function Content_Decode(ByVal t0) 
IF IsNull(t0) Or Len(t0)=0 Then 
Content_Decode="" 
Else 
Content_Decode=Replace(t0,"lt;","") 
Content_Decode=Replace(Content_Decode,"gt;",">") 
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),"nbsp;") 
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, "'", "#39;") 
t0=Replace(t0, """", "#34;") 
t0=Replace(t0, "", "lt;") 
t0=Replace(t0, ">", "gt;") 
End Select 
IF Instr(Lcase(t0),"expression")>0 Then 
t0=Replace(t0,"expression","e#173;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")", "lt;$1$2") 
IF Len(Sdcms_BadEvent)>0 Then t0=ReplaceText(t0,"(.[^>]*)("Sdcms_BadEvent")", "lt;$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,"nbsp;"," "),"quot;",chr(34)),"gt;",">"),"lt;","") 
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," ","nbsp;"),chr(34),"quot;"),">","gt;"),"","lt;") 
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=t1Chr(Cint("H"t3t5)) 
Else 
IF Abs(t6)=127 then 
t1=t1Chr(t6) 
Else 
t2=True 
t3=t5 
End IF 
End IF 
I=I+2 
Else 
t1=t1t4 
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 c0 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

以上就是asp中常用的字符串安全處理函數集合(過濾特殊字符等)的詳細內容,更多關于字符串 安全處理的資料請關注腳本之家其它相關文章!

標簽:唐山 甘南 南寧 滁州 來賓 迪慶 淮北 揭陽

巨人網絡通訊聲明:本文標題《asp中常用的字符串安全處理函數集合(過濾特殊字符等)》,本文關鍵詞  asp,中常,用的,字符串,安全,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《asp中常用的字符串安全處理函數集合(過濾特殊字符等)》相關的同類信息!
  • 本頁收集關于asp中常用的字符串安全處理函數集合(過濾特殊字符等)的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 永年县| 鹤峰县| 皋兰县| 天台县| 汝州市| 英吉沙县| 石楼县| 通渭县| 宣化县| 藁城市| 休宁县| 平乡县| 阿巴嘎旗| 英超| 揭阳市| 商河县| 邹平县| 吴桥县| 改则县| 秦皇岛市| 周至县| 新宁县| 阜平县| 香港 | 准格尔旗| 恩施市| 东城区| 河北省| 内黄县| 广丰县| 高唐县| 房山区| 房产| 沂南县| 章丘市| 凤山县| 浑源县| 梓潼县| 甘孜| 育儿| 泰兴市|