CFFEED Bug To Watch Out For

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”>

Raymond Camden
About Raymond Camden
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.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>