Filter special SQL characters

Source: Internet
Author: User

Function pop_sqlin (text)
If isnull (text) then
Pop_sqlin = ""
Exit Function
End if

Dim sqlwords
Set sqlwords = new Regexp
Sqlwords. ignorecase = true
Sqlwords. Global = true

Sqlwords. pattern = "(')"
TEXT = sqlwords. Replace (text ,"''")
Sqlwords. pattern = "(;)"
TEXT = sqlwords. Replace (text ,";")
Sqlwords. pattern = "(% )"
TEXT = sqlwords. Replace (text, "% ")
Sqlwords. pattern = "(and )"
TEXT = sqlwords. Replace (text, "and ")
Sqlwords. pattern = "(EXEC )"
TEXT = sqlwords. Replace (text, "EXEC ")
Sqlwords. pattern = "(execute )"
TEXT = sqlwords. Replace (text, "execute ")
Sqlwords. pattern = "(insert )"
TEXT = sqlwords. Replace (text, "insert ")
Sqlwords. pattern = "(select )"
TEXT = sqlwords. Replace (text, "select ")
Sqlwords. pattern = "(delete )"
TEXT = sqlwords. Replace (text, "delete ")
Sqlwords. pattern = "(update )"
TEXT = sqlwords. Replace (text, "Update ")
Sqlwords. pattern = "(count )"
TEXT = sqlwords. Replace (text, "Count ")
Sqlwords. pattern = "(CHR )"
TEXT = sqlwords. Replace (text, "CHR ")
Sqlwords. pattern = "(MID )"
TEXT = sqlwords. Replace (text, "mid ")
Sqlwords. pattern = "(master )"
TEXT = sqlwords. Replace (text, "Master ")
Sqlwords. pattern = "(truncate )"
TEXT = sqlwords. Replace (text, "truncate ")
Sqlwords. pattern = "(char )"
TEXT = sqlwords. Replace (text, "char ")
Sqlwords. pattern = "(declare )"
TEXT = sqlwords. Replace (text, "declare ")

Set sqlwords = nothing
Pop_sqlin = text
End Function

Function pop_sqlout (text)
If isnull (text) then
Pop_sqlout = ""
Exit Function
End if
TEXT = Replace (text ,"''","'")
TEXT = Replace (text ,";",";")
TEXT = Replace (text, "%", "% ")
TEXT = Replace (text, "and", "and ")
TEXT = Replace (text, "EXEC", "EXEC ")
TEXT = Replace (text, "execute", "execute ")
TEXT = Replace (text, "insert", "insert ")
TEXT = Replace (text, "select", "select ")
TEXT = Replace (text, "delete", "delete ")
TEXT = Replace (text, "Update", "Update ")
TEXT = Replace (text, "Count", "Count ")
TEXT = Replace (text, "CHR", "CHR ")
TEXT = Replace (text, "mid", "mid ")
TEXT = Replace (text, "Master", "Master ")
TEXT = Replace (text, "truncate", "truncate ")
TEXT = Replace (text, "char", "char ")
TEXT = Replace (text, "declare", "declare ")
Pop_sqlout = text
End Function

Function htmlencode (popstring)
If not isnull (popstring) then
Popstring = pop_sqlout (popstring)
Popstring = Replace (popstring, ">", "> ")
Popstring = Replace (popstring, "<", "<")
Popstring = Replace (popstring, CHR (32 ),"")
Popstring = Replace (popstring, CHR (9 ),"")
Popstring = Replace (popstring, CHR (34 ),""")
Popstring = Replace (popstring, CHR (39 ),"'")
Popstring = Replace (popstring, CHR (10) & CHR (10), "</P> <p> ")
Popstring = Replace (popstring, CHR (10), "<br/> ")
Popstring = Replace (popstring, CHR (36), "$ ")
Htmlencode = popstring
End if
End Function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.