[ALOY-578] Minify doesn't handle already-escaped quotes correctly
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2013-03-22T12:26:46.000+0000 |
Affected Version/s | Alloy 1.0.0 |
Fix Version/s | n/a |
Components | XML |
Labels | defect |
Reporter | Thomas Wilkinson |
Assignee | Tony Lukasavage |
Created | 2013-03-21T21:08:15.000+0000 |
Updated | 2014-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.
I need to withdraw this -- if I recall correctly in js " is meant to be equivalent to \" when inside single quotes