Re: String manipulation and HTML TAGS
- From: "Steven Burn" <somewhere@xxxxxxxxxxxxxxx>
- Date: Sun, 25 Sep 2005 00:40:33 +0100
You could still do that, with a little reverse thought (or using RegExp).
Dim strMyString
strMyString = Server.HTMLEncode(Request.Form("txtMessage"))
Response.Write FormatString(strMyString)
Function FormatString(sWhat)
'// Allow italics
sWhat = Replace(sWhat, "<i>", "<i>")
sWhat = Replace(sWhat, "</i>", "</i>")
'// Allow bold
sWhat = Replace(sWhat, "<b>", "<b>")
sWhat = Replace(sWhat, "</b>", "</b>")
'// Repeat as required
FormatString = sWhat
End Function
--
Regards
Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk
Keeping it FREE!
"adyda" <adyda.remove@xxxxxxxxxx> wrote in message
news:7KkZe.12412$kA.647892@xxxxxxxxxxxxxxx
> I'm not sure that this solution is what i was looking for..
> I was looking to some "cut-off" function to clear my string only from
those
> TAGS considered dangerouse. Formatting tags must be preserved
>
> f.e, if my string look like this
>
> <b>Hello<iframe src=http://myvirus.com></iframe> World</b>
> <script language=javascript src=http://myvirus.com/myvirus2.js />
> <i>How Are U?</i>
>
> output must be
>
> <b>Hello World</b><i>How Are U?</i>
>
> Many thanks anyway
>
>
>
> "Steven Burn" <somewhere@xxxxxxxxxxxxxxx> wrote in message
> news:ugcn2OVwFHA.3400@xxxxxxxxxxxxxxxxxxxxxxx
> > Dump your replace code and use;
> >
> > Response.Write Server.HTMLEncode(tmpText)
> >
> > This will HTML encode the whole of the post (including scripts).
> >
> > --
> > Regards
> >
> > Steven Burn
> > Ur I.T. Mate Group
> > www.it-mate.co.uk
> >
> > Keeping it FREE!
> >
> > "adyda" <adyda.remove@xxxxxxxxxx> wrote in message
> > news:TwjZe.12256$kA.637134@xxxxxxxxxxxxxxx
> >> Hy to all,
> >>
> >> I've developed a website using ASP (interdev)
> >> I've created a "forum" using an HTML area (http://www.htmlarea.com/)
as
> >> message board to have a word like formatting tool, but now I need to
> > cleanup
> >> the posted data from any script or other possible malicius tags (also
to
> >> prevent javascript error on my pages)
> >>
> >> So, I'm looking to the best solution to do this
> >>
> >> I've tried several solutions, using Replace, Left and Right functions,
> >> but
> >> there are to much "script TAGS" cases which can damage my code and
> >> anyway,
> >> if I past into my form complex pages from other websites, my pages
hangs
> >> when processing
> >>
> >> Here is an example
> >>
> >> ======
> >> tmpText=replace(tmpText,"<script","<!-st-")
> >> tmpText=replace(tmpText,"<object","<!-st-")
> >> tmpText=replace(tmpText,"<iframe","<!-st-")
> >> tmpText=replace(tmpText,"/script>","-en->")
> >> tmpText=replace(tmpText,"/object>","-en->")
> >> tmpText=replace(tmpText,"/iframet>","-en->")
> >> while not instr(tmpText,"<!-st-")=0
> >> tagStart=inStr(tmpText,"<!-st-")
> >> tagEnd=inStr(tmpText,"-en->")
> >> myTag=mid(tmpText,tagStart,tagEnd+4-(tagStart-1))
> >> tmpText=replace(tmpText,myTag,"")
> >> wend
> >> ======
> >>
> >> Any better idea or other usefull functions???
> >>
> >> thanks in advance
> >>
> >> Adriano
> >>
> >>
> >
> >
>
>
.
- References:
- String manipulation and HTML TAGS
- From: adyda
- Re: String manipulation and HTML TAGS
- From: Steven Burn
- Re: String manipulation and HTML TAGS
- From: adyda
- String manipulation and HTML TAGS
- Prev by Date: Re: MS VPN and script to map users drive.
- Next by Date: Re: Hiding Source Code
- Previous by thread: Re: String manipulation and HTML TAGS
- Next by thread: Re: String manipulation and HTML TAGS
- Index(es):
Relevant Pages
|