tracker issue : CF-3913893

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

String comparison bug

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/NotABug

Reporter/Name(from Bugbase): Rafael Salomon / Rafael Salomon (Rafael Salomon)

Created: 12/22/2014

Components: Language

Versions: 10.0

Failure Type:

Found In Build/Fixed In Build: Final /

Priority/Frequency: Major / All users will encounter

Locale/System: English / Win 2008 Server R2 64 bit

Vote Count: 0

Problem Description: it looks like ColdFusion converts some strings to numbers before comparing them which means that it thinks "00005197" and "+00005197" are the same string.

Steps to Reproduce:

<cfset stringOne = "00005197">
<cfset stringTwo = "+00005197">
<cfset areStringsEqual = (stringOne EQ stringTwo)>
<cfoutput><br>[#areStringsEqual#]</cfoutput>

Actual Result:
strings are equal

Expected Result:
strings are not equal

Any Workarounds:
Compare(stringOne,stringTwo) produces the correct result

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

Watson Bug ID:	3913893

External Customer Info:
External Company:  
External Customer Name: Rafael Salomon
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

Comments:

This isn't a bug. If you want to do a STRING comparison, you need to actually do one, using compare(): <cfset doStringsCompare = compare(stringOne,stringTwo)> <cfoutput><br>[#doStringsCompare#]</cfoutput> If you use EQ, CF will try to case each side to numerics. And in this case, those two values are the same.
Comment by External U.
9224 | December 22, 2014 01:33:39 PM GMT