Status/Resolution/Reason: Closed/Withdrawn/Duplicate
Reporter/Name(from Bugbase): John Nelson / John Nelson (John Nelson)
Created: 10/10/2014
Components: Language, Serialization
Versions: 11.0
Failure Type: Incorrect w/Workaround
Found In Build/Fixed In Build: CF11_Final /
Priority/Frequency: Normal / Most users will encounter
Locale/System: ALL / Win 2008 Server R2 64 bit
Vote Count: 15
Duplicate ID: CF-3941059
Problem Description: When encoding binary data (in this case an image) as Base64 and adding it to a struct which is then serialized into JSON (I have not tested XML serialization), some combinations of characters are altered which should not be, resulting in invalid Base64 data. Specifically, "u+" is changed to "\u" which would be invalid Base64 since "\" is not an included character. I'm assuming this is happening because "u+" is the common prefix for Unicode characters and "\u" would allow the browser to interpret it as such. However, in a Base64 string, there are no Unicode characters and changing the string at best makes it unusable, at worst it would corrupt the data into something very different from what was expected.
This issue does not occur every time as "u+" may not occur in every Base64 string, but it has happened with a number of images I have encoded and sent using our REST web service.
Steps to Reproduce:
Encode a binary object as Base64 using either binaryEncode() or toBase64().
Insert the resulting string into a struct.
Serialize the struct into JSON using serializeJSON().
Deserialize and attempt to decode the Base64 string.
Actual Result:
Attempting to decode the produced string results in an error which reports that it is not valid Base64.
Example Actual Result (excerpt): PFpA4ntd/j58gtZuyiJ\u9DdFEgv7lOKdVty6ynw
Expected Result:
Attempting to decode the produced string should result in the creation of the same binary data as what was encoded (an image, file, etc.).
Example Expected Result (excerpt): PFpA4ntd/j58gtZuyiJu+9DdFEgv7lOKdVty6ynw
Any Workarounds:
I was able to work around the issue by changing the "+" and "/" characters in the Base64 with other characters, in this case: "@^$%" and "*&%^", respectively.
After serializing the struct, I replaced those strings of characters with the appropriate Base64 characters and returned that instead of the direct result of the serializeJSON().
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3837347
External Customer Info:
External Company:
External Customer Name: js.nelson
External Customer Email:
External Test Config: My Hardware and Environment details:
Windows Server 2008 R2
IIS 7.5.7600.16385
64-bit ColdFusion 11 Update 1
Running on a VMWare Virtual Machine:
Intel Xeon E2-2680 v2 @ 2.8GHz (2 processors)
8 GB RAM
64-bit OS
Attachments:
- October 22, 2014 00:00:00: 1_TestImage.jpg
- March 10, 2015 00:00:00: 2_Stryker_model_MW3.png
- March 18, 2015 00:00:00: 3_jsonFail.zip
Comments: