tracker issue : CF-3585643

select a category, or use search below
(searches all categories and all time range)

Trim() adds doubles apostrophes in cfquery

| View in Tracker

Status/Resolution/Reason: Closed/Won't Fix/NotWorthEffort

Reporter/Name(from Bugbase): Rory Brown / Rory Brown (gozargozarian3)

Created: 06/26/2013

Components: Database

Versions: 10.0

Failure Type: Data Corruption

Found In Build/Fixed In Build: Final /

Priority/Frequency: Minor / All users will encounter

Locale/System: English / Windows 7

Vote Count: 2

Problem Description:
When using trim inside of a cfquery, but not as part of the query, all single apostrophes are duplicated into two.

Steps to Reproduce:
Run the following code:
<cfset testCont = "This isn't my test ">
<cfset expected = Trim(testCont)>

<cfquery name="qryTest" datasource="MyDataSource">
	<cfset badresult = Trim(testCont)>
	SELECT TOP 1 * FROM something

<cfoutput>#expected# - #badresult#</cfoutput>

Actual Result:
The variable "badresult" contains duplicated apostrophes, but the "expected" variable is normal.

Expected Result:
I would expect Trim() to always work as documented.  Apostrophes should only duplicate if used without a cfqueryparam and without PreserveSingleQuotes()

Any Workarounds:
Do your Trimming outside of a query.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3585643

Deployment Phase:	Release Candidate

External Customer Info:
External Company:  
External Customer Name: gozargozarian3
External Customer Email:  
External Test Config: My Hardware and Environment details: Windows 7, Coldfusion Enterprise 10, IIS 7.5



The Left() function appears to do this too. There may be others.
Comment by External U.
15117 | June 26, 2013 03:18:33 PM GMT
Something is definitely wrong. Here are additional failed comparisons that I performed using CF 10,0,10,284825 (64 bit w/Tomcat ToString, JavaCast and SerializeJSON are the only functions I tested that weren't negatively impacted. JSString This isn\'\'t my test JavaCast This isn't my test LCase this isn''t my test LJustify This isn''t my test LTrim This isn''t my test Left This isn''t my te MID s isn''t RJustify This isn''t my test RTrim This isn''t my test RepeatString This isn''t my test This isn''t my test Right is isn''t my test SerializeJSON " This isn't my test " ToString This isn't my test Trim This isn''t my test UCase THIS ISN''T MY TEST Wrap This isn'' t my test XmlFormat This isn&apos;&apos;t my test
Comment by External U.
15118 | June 26, 2013 05:52:53 PM GMT
I haven't fully migrated to ColdFusion 10 yet, but it's going to be time consuming to review code to determine the potential impact of this bug.
Vote by External U.
15125 | June 26, 2013 05:55:37 PM GMT
This impacts CFMX7.0.2 and CF9.0.2 as well (my CF8 instance isn't working at the moment for some reason). So I question Jamo's claim that it's going to impact their upgrade process much. FWIW, the problem DOESN'T exist on CF5. -- Adam
Comment by External U.
15119 | June 27, 2013 12:24:40 AM GMT
This should be fixed, but I disagree it's "very high", and it is also very work-aroundable-able. Either don't put unrelated CF logic within <cfquery> tags (which would apply even if this issue didn't exist, or simply use preserveSingleQuotes(). -- Adam
Vote by External U.
15126 | June 27, 2013 12:26:43 AM GMT
I posted some sample code at Pastebin so that other affected ColdFusion functions can be tested. (The bug can be "verified" by pasting the above code to Railo correctly returns the variables without the double quote bug.)
Comment by External U.
15120 | June 27, 2013 08:56:11 AM GMT
Not a good use case. It works fine for cfqueryparam.
Comment by Himavanth R.
15121 | December 09, 2013 07:33:59 AM GMT
This is flagged as "to test", but "never fix". Is that right? -- Adam
Comment by External U.
15122 | December 09, 2013 09:05:08 AM GMT
Lol! Marked "NotWorthEffort". That is pretty much the label you guys can use on your whole Coldfusion product. Well, it's "NotWorthEffort" to keep paying you money for a product that has only grown more buggy. We've already been planning the migration to Railo anyway.
Comment by External U.
15123 | December 16, 2013 11:56:57 AM GMT
First of all, this is not a new bug/behavior. It has been like this since CF 5. So @Jamo, you don't need to worry about the issue in migration because of this. Second, I don't see any reason to write code like <cfset> inside cfquery tag. Query tag escapes all the strings in its body and this bug is a side effect of that. Now, this can definitely be fixed but given that it is such a rare scenario and there is a very easy workaround, it is not worth spending time and effort fixing this bug. There are many other important bugs that need to be fixed and I am sure you would also prefer getting them fixed rather than us spending time on such trivial bugs.
Comment by Himavanth R.
15124 | December 17, 2013 12:29:25 AM GMT