Submit Your Article
Home Articles News Tutorials Videos Add An Article
Topics: Design Photoshop Programming PHP CSS Java Database Web Development Javascript Ajax
– Close + Open

Find Out More About DevWebPro!

Sign up for the newsletter


» Terms & Conditions

Welcome to the New DevWebPro!

DevWebPro Includes:
  Hundreds Of Tutorials   Developer News
  Unique Gadget Videos   Tons of Topics to Discuss
  Expert Advice   We Will Publish Your Articles

CFFEED Bug To Watch Out For

By: Raymond Camden
Tuesday, November 20th, 2007
Text: Decrease Font Size Increase Font Size | Print Print Article | Share: Delicious Digg StumbleUpon Post to Twitter Post to Facebook

I’ve blogged before about how xmlFormat() is a bit buggy.

While it will remove most characters, including “high ascii” characters in the range of 128-255, it will gleefully ignore other high ascii characters, for example, character 8220 which is the funky Microsoft Word quote.

Unfortunately it looks like the same code used for xmlFormat is used to escape text when you create feeds with CFFEED.

Consider the following example:

<cfset getEntries = queryNew("publisheddate,content,title")>

<cfset queryAddRow(getEntries)>
<cfset querySetCell(getEntries,”title”, “LAST ENTRY”)>
<cfset querySetCell(getEntries,”content”, “<b>Test</b>”)>
<cfset querySetCell(getEntries,”publisheddate”, now())>

<cfset queryAddRow(getEntries)>
<cfset querySetCell(getEntries,”title”, “LAST ENTRY2″)>
<cfset querySetCell(getEntries,”content”, “#chr(8220)#Test#chr(8220)#”)>
<cfset querySetCell(getEntries,”publisheddate”, now())>

<cfset props = {version=”rss_2.0″,title=”Test Feed”,link=”http://127.0.0.1″,description=”Test”}>

<cffeed action=”create” properties=”#props#” query=”#getEntries#” xmlVar=”result”>

<cfcontent type=”text/xml” reset=”true”><cfoutput>#result#</cfoutput>

The first entry will correctly show up in Firefox, but the second will not, and if you view source, you see the B tags are properly escaped, but the funky MS Word character is not. Now obviously I can make sure to “clean” my data before it gets used in the feed, but I wasn’t aware this was an even an issue until a friend reported that the feed at ColdFusionBloggers suddenly turned up empty. For now I’ve switched to the solution below – which is not a good solution, but I needed a quick fix.

<!--- clean up bad stuff --->
<cfloop query="items">
<cfset fixedcontent = replaceList(content, "#chr(25)#,#chr(212)#,#chr(248)#,#chr(937)#,#chr(8211)#", "")>
<cfset fixedcontent = replaceList(fixedcontent,chr(8216) & "," & chr(8217) & "," & chr(8220) & "," & chr(8221) & "," & chr(8212) & "," & chr(8213) & "," & chr(8230),"',',"","",--,--,...")>
<cfset querySetCell(items, "content", fixedcontent, currentRow)>
</cfloop>

<cffeed action=”create” properties=”#props#” columnMap=”#cmap#” query=”#items#” xmlVar=”result”>

Topics: , ,

About the Author:
Raymond Camden, ray@camdenfamily.com http://ray.camdenfamily.com Raymond Camden is Vice President of Technology for roundpeg, Inc. A long time ColdFusion user, Raymond has worked on numerous ColdFusion books and is the creator of many of the most popular ColdFusion community web sites. He is an Adobe Community Expert, user group manager, and the proud father of three little bundles of joy.
DevWebPro is an iEntry Network ® publication - © 1998-2010 All Rights Reserved