Titanium JIRA Archive
Alloy (ALOY)

[ALOY-578] Minify doesn't handle already-escaped quotes correctly

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionInvalid
Resolution Date2013-03-22T12:26:46.000+0000
Affected Version/sAlloy 1.0.0
Fix Version/sn/a
ComponentsXML
Labelsdefect
ReporterThomas Wilkinson
AssigneeTony Lukasavage
Created2013-03-21T21:08:15.000+0000
Updated2014-06-22T13:23:11.000+0000

Description

A had a string literal that contains escaped quotes: var JSONtest = JSON.parse('{"result": "{\"Xzibit\":{\"JSON\":\"within JSON\"}}", "id": "7ca16380-56c5-49d4-bfb3-55d8c8f9177e" }'); When the parser parsed it, it replaced the single-quotes with double quotes, and escape the qouble-quotes that weren't already escaped, but didn't escape the escaping of the already escaped quotes. The resources version of the code was this: var JSONtest = JSON.parse("{\"result\": \"{\"Xzibit\":{\"JSON\":\"within JSON\"}}\", \"id\": \"7ca16380-56c5-49d4-bfb3-55d8c8f9177e\" }"); when it should have been this (note some places have three backslashes): var JSONtest = JSON.parse("{\"result\": \"{\\\"Xzibit\\\":{\\\"JSON\":\\\"within JSON\\\"}}\", \"id\": \"7ca16380-56c5-49d4-bfb3-55d8c8f9177e\" }"); Marking as minor as (a) There is a workaround, and (b) this code only written to test another issue with my code.

Comments

  1. Thomas Wilkinson 2013-03-21

    I need to withdraw this -- if I recall correctly in js " is meant to be equivalent to \" when inside single quotes

JSON Source