----- Original Message -----
From: "Russ" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Monday, February 24, 2003 12:16 PM
Subject: Allowing specific HTML tags to be displayed


> I've still not had any luck trying to get Replace or ReReplace to allow
> a set of specific codes when displaying information from a database.
>
> I'm hoping to allow for only specific sets:  Italics, Bold, A HREF and
> IMG SRC and I'm baffled as to how to get this to work.  It's a bit of a
> repost, but I'm really striking out.


Here is how I would approach it:

1. Use the ReplaceList() function to replace all permitted tags and matching
end-tags with tokens unique to each tag.  The tokens will have to be fairly
unique - using control characters would be a good idea to replace the brackets.

<cfset bmarker = Chr(2)>
<cfset emarker = Chr(3)>
<cfset mystring = ReplaceList(mystring,
  "<b,<i,<u,/b>,/i>,/u>",
  "#bmarker#b,#bmarker#i,#bmarker#u,/b#emarker#,/i#emarker#,/u#emarker#")>

2. Invalidate all of the remaining HTML by either stripping out the entire HTML
tags, or by turning the < and > into special &lt; and &gt; characters.  You can
do the latter with:

<cfset mystring = ReplaceList(mystring, "<,>", "&lt;,&gt;")>

3. Replace the tokens with their original tags (i.e. reversing step 1).

<cfset mystring = ReplaceList(mystring,
  "#bmarker#b,#bmarker#i,#bmarker#u,/b#emarker#,/i#emarker#,/u#emarker#",
  "<b,<i,<u,/b>,/i>,/u>")>


Jim

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to