• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

html parsing

Explorer ,
Jan 31, 2007 Jan 31, 2007

Copy link to clipboard

Copied

hi,

I have the comment field for user to enter the comments. Sometime they enter the html code, so i am looking for someting to script out all the html from the comments but i don't know how. Is anyone has experiences on this?

Thanks
TOPICS
Advanced techniques

Views

394

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 31, 2007 Jan 31, 2007

Copy link to clipboard

Copied

Sometime they enter the html code, so i am looking for someting to
script out all the html from the comments but i don't know how. Is
anyone has experiences on this?


A quick and easy way to render the HTML ineffective is to wrap the input
and/or output statements with the HTMLCodeFormat() or HTMLEditFormat()
functions. These functions escape all the angle brackets(<|>) and other
symbols so that the HTML code is just displayed, not rendered by the
browser.

If you want to strip the HTML that takes a bit more effort, but I like
using these functions as a last line of defense even when using other
techniques.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 31, 2007 Jan 31, 2007

Copy link to clipboard

Copied

is there any example out there that you know? or can you provide me an example?

Thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 31, 2007 Jan 31, 2007

Copy link to clipboard

Copied

is there any example out there that you know? or can you provide me an
example?

Thanks

Example of what? Using those functions.

Change something like this:
<cfoutput>#stuffAnUserInput#<cfoutput>
TO:
<cfoutput>#htmlEditFormat(stuffAnUserInput)#</cfoutput>

And|Or change something like this:

<cfquery ...>
INSERT INTO aTable
{aFieldOfUserInput)
('#thmlEditFormat(aFormFieldWithUserInput)#)
</cfquery><!--- Note: this could considerable lengthen the text input
into the database. Size the field accordingly. --->

One would want to add a corresponding change to any related UPDATE
queries as well.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 31, 2007 Jan 31, 2007

Copy link to clipboard

Copied

the safetext UDF can also help you out..

http://www.cflib.org/udf.cfm?id=56

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 31, 2007 Jan 31, 2007

Copy link to clipboard

Copied

LATEST
This regex effectively removes all html from a string.

<cfset string2 = REReplaceNoCase(string1,"<[^>]*>","","all") />

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation