Karl Blessing
Programmer
I have this code sniplet that does some HTML Striping for viewing , but though it does correctly replace tabs, spaces, and any Amperstands (For other html encoded peices that didnt quite make it)
The question is however, how do I get it to leave certain tags "as is"
for example, I would like to leave <img...> , <a ... >...</a>, and a couple other tags intact so that they show up appropiratly. The reason I have it striping out all the tags is to keep both the message from looking cluttered in html code, and to keep the web-based email system more secure from javascript and other posible automatic things.
Karl Blessing aka kb244{fastHACK}
Code:
Function ToHTML(ByRef pString)
Dim lObjRegExp
Dim lLngStart
Dim lLngEnd
If VarType(pString) = vbNull Then Exit Function
ToHTML = pString
' Parse TAGS
Set lObjRegExp = New RegExp
lObjRegExp.Global = True
lObjRegExp.Pattern = "<[^>]*>"
ToHTML = lObjRegExp.Replace(pString, "")
Set lObjRegExp = Nothing
' HTML Encoding
ToHTML = Server.HTMLEncode(ToHTML)
' Change Carriage Returns and Line Feeds to HTML
ToHTML = Replace(ToHTML, vbCrLf, "<BR>")
ToHTML = Replace(ToHTML, vbCr, "<BR>")
ToHTML = Replace(ToHTML, vbLf, "<BR>")
ToHTML = Replace(ToHTML, "&", "&")
' Change Tabs to HTML
ToHTML = Replace(ToHTML, vbTab, " ")
' Change double-space to HTML
While Not InStr(1, ToHTML, " ") = 0
ToHTML = Replace(ToHTML, " ", " ")
Wend
End Function
The question is however, how do I get it to leave certain tags "as is"
for example, I would like to leave <img...> , <a ... >...</a>, and a couple other tags intact so that they show up appropiratly. The reason I have it striping out all the tags is to keep both the message from looking cluttered in html code, and to keep the web-based email system more secure from javascript and other posible automatic things.
Karl Blessing aka kb244{fastHACK}