這裏是我的固定創建有趣的人物:
我使用FN_CLEAN來清理用於數據庫插入/更新的東西:
function fn_clean(FixWhat)
if (isempty(FixWhat) or isnull(FixWhat) or FixWhat="") then
FixWhat=""
else
apos=chr(39)
quot=chr(34)
FixWhat=trim(FixWhat)
FixWhat=replace(FixWhat," "," ",1,-1,1)
FixWhat=replace(FixWhat,"''",apos & apos,1,-1,1)
FixWhat=replace(FixWhat,"'''",apos,1,-1,1)
FixWhat=replace(FixWhat,VBNullChar,"",1,-1,1)
FixWhat=replace(FixWhat,VBNullString,"",1,-1,1)
FixWhat=replace(FixWhat,VBTab," ",1,-1,1)
FixWhat=replace(FixWhat,VBVerticalTab," ",1,-1,1)
FixWhat=replace(FixWhat,"<ahref=","<a href=",1,-1,1)
FixWhat=replace(FixWhat,"<ahref =","<a href=",1,-1,1)
FixWhat=replace(FixWhat,"<imgsrc","<img src",1,-1,1)
FixWhat=replace(FixWhat,"<spanclass=","<span class=",1,-1,1)
FixWhat=replace(FixWhat,"<spanclass =","<span class=",1,-1,1)
FixWhat=replace(FixWhat,"//<![CDATA[","",1,-1,1)
FixWhat=replace(FixWhat,"//]]","",1,-1,1)
FixWhat=replace(FixWhat,"&","&",1,-1,1)
FixWhat=replace(FixWhat,"amp;","&",1,-1,1)
FixWhat=replace(FixWhat,"&","&",1,-1,1)
FixWhat=replace(FixWhat,"&&","&",1,-1,1)
FixWhat=replace(FixWhat,"&&","&",1,-1,1)
FixWhat=replace(FixWhat,"<","<",1,-1,1)
FixWhat=replace(FixWhat,">",">",1,-1,1)
FixWhat=replace(FixWhat,"/","/",1,-1,1)
'FixWhat=replace(FixWhat,"../../../images/","/images/",1,-1,1)
FixWhat=replace(FixWhat,"’",apos,1,-1,1)
FixWhat=replace(FixWhat,"’",apos,1,-1,1)
FixWhat=replace(FixWhat,"`",apos,1,-1,1)
'FixWhat=replace(FixWhat,chr(145),apos,1,-1,1)
'FixWhat=replace(FixWhat,chr(146),apos,1,-1,1)
'FixWhat=replace(FixWhat,chr(180),apos,1,-1,1)
'FixWhat=replace(FixWhat,chr(184),apos,1,-1,1)
FixWhat=replace(FixWhat,"_new","_BLANK",1,-1,1)
FixWhat=replace(FixWhat,"_NEW","_BLANK",1,-1,1)
'FixWhat=replace(FixWhat,"ñ","ñ",1,-1,1)
'quotes
'FixWhat=replace(FixWhat,chr(132),quot,1,-1,1)
'FixWhat=replace(FixWhat,chr(147),quot,1,-1,1)
'FixWhat=replace(FixWhat,chr(148),quot,1,-1,1)
'FixWhat=replace(FixWhat,chr(152),quot,1,-1,1)
'FixWhat=replace(FixWhat,chr(168),quot,1,-1,1)
'hyphens
'FixWhat=replace(FixWhat,chr(150),"-",1,-1,1)
'FixWhat=replace(FixWhat,chr(151),"--",1,-1,1)
'dot dot dot
'FixWhat=replace(FixWhat,chr(133),"...",1,-1,1)
'line feed
'FixWhat=replace(FixWhat,chr(10),"[chr-10 was here]",1,-1,1)
'FixWhat=replace(FixWhat,chr(12),"[chr-12 was here]",1,-1,1)
'FixWhat=replace(FixWhat,chr(13),"[chr-13 was here]",1,-1,1)
'CR
'FixWhat=replace(FixWhat,chr(21),"<br>",1,-1,1)
'now for everything higher than char 128
'for i = 129 to 255
' c = "&#" & i & ";"
' FixWhat = replace(FixWhat,Chr(i),"'",1,-1,1)
'next
'FixWhat=replace(FixWhat,quot,quot & quot)
'FixWhat=replace(FixWhat,"<br>" & vbCrLf & "<br>" & vbCrLf & "<br>" & vbCrLf,"<br>" & vbCrLf & "<br>" & vbCrLf,1,-1,1)
FixWhat=replace(FixWhat,vbCrLf & vbCrLf,vbCrLf,1,-1,1)
'FixWhat=replace(FixWhat,"<br><br><br><br>","<br><br>",1,-1,1)
'FixWhat=replace(FixWhat,"<br><br><br>","<br><br>",1,-1,1)
'FixWhat=replace(FixWhat,"<table><br>","<table>",1,-1,1)
'FixWhat=replace(FixWhat,"</td><br>","</td>",1,-1,1)
'FixWhat=replace(FixWhat,"<tr><br>","<tr>",1,-1,1)
'FixWhat=replace(FixWhat,"<br><tr>","<tr>",1,-1,1)
'FixWhat=replace(FixWhat,"</tr><br>","</tr>",1,-1,1)
'FixWhat=replace(FixWhat,"<br></tr>","</tr>",1,-1,1)
'FixWhat=replace(FixWhat,"<br><embed","<embed",1,-1,1)
'FixWhat=replace(FixWhat,"background=" & quot & " ","background=" & quot & quot & " ",1,-1,1)
FixWhat=replace(FixWhat,"alt =","title=",1,-1,1)
FixWhat=replace(FixWhat,"alt=","title=",1,-1,1)
FixWhat=replace(FixWhat,"alt= ","alt= ",1,-1,1)
FixWhat=replace(FixWhat,"alt= ","title=",1,-1,1)
FixWhat=replace(FixWhat,"title=" & chr(34) & chr(34),"title=image",1,-1,1)
FixWhat=replace(FixWhat,"title=" & chr(34) & chr(32),"title=image ",1,-1,1)
FixWhat=replace(FixWhat,"align=" & quot & " ","align=left ",1,-1,1)
FixWhat=replace(FixWhat,"border=" & quot & " "," ",1,-1,1)
FixWhat=replace(FixWhat,"this=" & quot & " "," ",1,-1,1)
FixWhat=replace(FixWhat,"width=" & quot & " ","width=10 ",1,-1,1)
FixWhat=replace(FixWhat,"x=" & quot & " "," ",1,-1,1)
FixWhat=replace(FixWhat,"[quote]",""",1,-1,1)
FixWhat=replace(FixWhat,quot,""",1,-1,1)
FixWhat=replace(FixWhat,"'","'",1,-1,1)
end if
fn_clean=FixWhat
End Function
,這一次我用「骯髒的IT UP FOR SCREEN /輸入框,ETC:
Function fn_dirty(FixWhat)
if (isnull(FixWhat) or FixWhat="") then
FixWhat=""
else
FixWhat=trim(FixWhat)
FixWhat=replace(FixWhat,"<ahref","<a href",1,-1,1)
FixWhat=replace(FixWhat,"<spanclass","<span class",1,-1,1)
'FixWhat=replace(FixWhat,"ñ","ñ",1,-1,1)
FixWhat=replace(FixWhat," "," ",1,-1,1)
FixWhat=replace(FixWhat,"’","'",1,-1,1)
FixWhat=replace(FixWhat,"'","'",1,-1,1)
FixWhat=replace(FixWhat,"%27","'",1,-1,1)
FixWhat=replace(FixWhat,"'","'",1,-1,1)
FixWhat=replace(FixWhat,"’","'",1,-1,1)
FixWhat=replace(FixWhat,"/","/",1,-1,1)
FixWhat=replace(FixWhat,"''''","'''",1,-1,1)
FixWhat=replace(FixWhat,""",chr(34),1,-1,1)
FixWhat=replace(FixWhat,"%22",chr(34),1,-1,1)
FixWhat=replace(FixWhat,chr(13) & chr(10),"",1,-1,1)
'FixWhat=replace(FixWhat," " & " ","",1,-1,1)
'FixWhat=replace(FixWhat,vbCrLf & vbCrLf,vbCrLf,1,-1,1)
'FixWhat=replace(FixWhat,chr(34)&chr(34)&chr(34),chr(34),1,-1,1)
'FixWhat=replace(FixWhat,chr(10),"[chr10 was here]",1,-1,1)
'FixWhat=replace(FixWhat,chr(12),"[chr12 was here]",1,-1,1)
'FixWhat=replace(FixWhat,chr(13),"[chr13 was here]",1,-1,1)
'FixWhat=replace(FixWhat,chr(34) & chr(34),chr(34),1,-1,1)
'FixWhat=replace(FixWhat,"alt='" & chr(32) & "'","alt=Put-image-title-here-instead-of-OceanMedia.net" & chr(32),1,-1,1)
'FixWhat=replace(FixWhat,"alt=" & chr(34) & chr(32) & chr(34),"title=Put-image-title-here-instead-of-OceanMedia.net" & chr(32),1,-1,1)
'FixWhat=replace(FixWhat,"alt='" & chr(32),"alt=Put-image-title-here-instead-of-OceanMedia.net" & chr(32),1,-1,1)
'FixWhat=replace(FixWhat,"alt='" & chr(32),"alt=Put-image-title-here-instead-of-OceanMedia.net" & chr(32),1,-1,1)
'FixWhat=replace(FixWhat,"alt=" & chr(34) & chr(32),"alt=Put-image-title-here-instead-of-OceanMedia.net" & chr(32),1,-1,1)
FixWhat=replace(FixWhat,"title=","alt=",1,-1,1)
'FixWhat=replace(FixWhat,"title='" & chr(32) & "'","title=Put-image-title-here-instead-of-OceanMedia.net" & chr(32),1,-1,1)
'FixWhat=replace(FixWhat,"title=" & chr(34) & chr(32) & chr(34),"title=Put-image-title-here-instead-of-OceanMedia.net" & chr(32),1,-1,1)
'FixWhat=replace(FixWhat,"title='" & chr(32),"title=Put-image-title-here-instead-of-OceanMedia.net" & chr(32),1,-1,1)
'FixWhat=replace(FixWhat,"title='" & chr(32),"title=Put-image-title-here-instead-of-OceanMedia.net" & chr(32),1,-1,1)
'FixWhat=replace(FixWhat,"title=" & chr(34) & chr(32),"title=Put-image-title-here-instead-of-OceanMedia.net" & chr(32),1,-1,1)
FixWhat=replace(FixWhat,"src=" & chr(34) & chr(32),"",1,-1,1)
FixWhat=replace(FixWhat,"src=" & chr(34) & "/images","src=" & chr(34) & "images",1,-1,1)
FixWhat=replace(FixWhat,"background=" & chr(34) & chr(32),"background=" & chr(34) & chr(34) & chr(32),1,-1,1)
FixWhat=replace(FixWhat,"x=" & chr(34) & chr(32)," ",1,-1,1)
FixWhat=replace(FixWhat,"&","&",1,-1,1)
FixWhat=replace(FixWhat,"amp;","&",1,-1,1)
FixWhat=replace(FixWhat,"&","&",1,-1,1)
FixWhat=replace(FixWhat,"&&","&",1,-1,1)
FixWhat=replace(FixWhat,"&&","&",1,-1,1)
FixWhat=replace(FixWhat,"<","<",1,-1,1)
FixWhat=replace(FixWhat,">",">",1,-1,1)
'FixWhat=replace(FixWhat,"&","&",1,-1,1)
FixWhat=replace(FixWhat,"//<![CDATA[","",1,-1,1)
FixWhat=replace(FixWhat,"//]]","",1,-1,1)
FixWhat=replace(FixWhat,"<TABLE","<table",1,-1,1)
FixWhat=replace(FixWhat,"<TBODY>","<tbody>",1,-1,1)
FixWhat=replace(FixWhat,"<TR","<tr",1,-1,1)
FixWhat=replace(FixWhat,"<TD","<td",1,-1,1)
FixWhat=replace(FixWhat,"</TR>","</tr>",1,-1,1)
FixWhat=replace(FixWhat,"</TD>","</td>",1,-1,1)
FixWhat=replace(FixWhat,"<html><br>","<html>",1,-1,1)
FixWhat=replace(FixWhat,"<head><br>","<head>",1,-1,1)
FixWhat=replace(FixWhat,"<body><br>","<body>",1,-1,1)
FixWhat=replace(FixWhat,"<br><tbody>","<tbody>",1,-1,1)
FixWhat=replace(FixWhat,"<tbody><br>","<tbody>",1,-1,1)
FixWhat=replace(FixWhat,"<br><tr>","<tr>",1,-1,1)
FixWhat=replace(FixWhat,"<tr><br>","<tr>",1,-1,1)
FixWhat=replace(FixWhat,"<br><td","<td",1,-1,1)
FixWhat=replace(FixWhat,"<br></html>","</html>",1,-1,1)
'FixWhat=replace(FixWhat,"#34;#34;#34;","""",1,-1,1)
'FixWhat=replace(FixWhat,"#39;#39;#39;","''",1,-1,1)
'FixWhat=replace(FixWhat,""""","""",1,-1,1)
'FixWhat=replace(FixWhat,"'''","''",1,-1,1)
end if
fn_dirty=FixWhat
End Function
你似乎有一個字符編碼問題。看看這篇文章https://www.hanselman.com/blog/InternationalizationAndClassicASP.aspx – John
謝謝,它似乎被解決 –