Re: String manipulation and HTML TAGS

Tech-Archive recommends: Speed Up your PC by fixing your registry



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, "&lt;i&gt;", "<i>")
sWhat = Replace(sWhat, "&lt;/i&gt;", "</i>")
'// Allow bold
sWhat = Replace(sWhat, "&lt;b&gt;", "<b>")
sWhat = Replace(sWhat, "&lt;/b&gt;", "</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
> >>
> >>
> >
> >
>
>


.



Relevant Pages

  • Re: Advice needed: Text editor with tags.
    ... With Docbook, theoretically, you are writing purely the ... > your desired formatting is quite a mammoth undertaking, ... come up with a set of tags for the XML file so I can try out in Tcl. ... All editing functions in the text widget available. ...
    (comp.lang.tcl)
  • Re: Title attribute in link
    ... I'm assuming people think I'm using this opportunity to keyword stuff my ... pages or links without going to the website to see how it is being used. ... Contents / privacy policy etc. ... the title tags tp be there? ...
    (alt.internet.search-engines)
  • Re: Index entry format not consistent
    ... Go to one or two of the text paragraphs containing index tags that are ... Choose Edit>Clear>Clear Formatting. ... > index entries with the same index level from marked text with the same ...
    (microsoft.public.mac.office.word)
  • RE: Extracting data from Word 2003 using XSLT
    ... The contents between these tags will be the text that the user ... >> and extracts the text including the formatting. ... The XSLT outputs an XML document containing the text ... >> The examples available in mdsn talk about using XSD for defining the Data ...
    (microsoft.public.word.vba.general)
  • Re: Automation: Inserting HTML text into Word 2000
    ... text then you'll have to strip off the tags and apply the formatting as ... expecting Windows to magically realise that the tags are formatting rather ... > I'm fine inserting text, images etc at bookmarks within a Word template ... > plain text rather than HTML. ...
    (microsoft.public.word.vba.general)