From 19917cb0b6ec0ded644eeb3bf1566d83ffe63031 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Mon, 16 Jan 2017 16:13:47 -0800 Subject: [PATCH] Fix issue #142. --- CHANGELOG.md | 11 ++++++----- lib/jsonview.js | 2 +- package.json | 2 +- tests/issue142.json | 1 + tests/issue142b.json | 4 ++++ tests/issue142c.json | 3 +++ tests/issue50.json | 1 + 7 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 tests/issue142.json create mode 100644 tests/issue142b.json create mode 100644 tests/issue142c.json create mode 100644 tests/issue50.json diff --git a/CHANGELOG.md b/CHANGELOG.md index a9c24d4..3d3d5ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +JSONView 1.2.3 +--- +* Fixed a case where JSON would fail to parse if a string containing a number was preceded by a quote that was preceded by an escaped slash. + JSONView 1.2.2 --- * Fixed a case where JSON would fail to parse if a string containing a number also contained escaped quotes. @@ -97,17 +101,14 @@ JSONView 0.2 --- * .json files can be opened in JSONView from the local machine. -* Added Bulgarian, German, Hungarian, and (partial) Turkish translations. Thanks to - Стоян Димитров, Archaeopteryx, Team erweiterungen.de, MIKES KASZMÁN István and Ersen Yolda from BabelZilla.org. +* Added Bulgarian, German, Hungarian, and (partial) Turkish translations. Thanks to Стоян Димитров, Archaeopteryx, Team erweiterungen.de, MIKES KASZMÁN István and Ersen Yolda from BabelZilla.org. * Compatible with FF 3.5.* JSONView 0.1 --- * String values which contain only a URL are displayed as a clickable link. Props to stig.murberg for the patch. -* Added Catalan, Spanish, Japanese, Portugese (Brazil), Russian, and Simplified Chinese translations. Thanks to - Fani Kozolchyk, and Xavi Ivars - Softcatalà, hoolooday, drry, Marcelo Ghelman (ghelman.net), Пирятинский Виталий, - and urko from BabelZilla.org. +* Added Catalan, Spanish, Japanese, Portugese (Brazil), Russian, and Simplified Chinese translations. Thanks to Fani Kozolchyk, and Xavi Ivars - Softcatalà, hoolooday, drry, Marcelo Ghelman (ghelman.net), Пирятинский Виталий, and urko from BabelZilla.org. JSONView 0.1b3: --- diff --git a/lib/jsonview.js b/lib/jsonview.js index 6ad5c18..e95800a 100644 --- a/lib/jsonview.js +++ b/lib/jsonview.js @@ -107,7 +107,7 @@ var JSONView = Class({ if (str[i] === '"') { var escaped = (i > 0 && str[i - 1] === '\\') && - (i > 1 || str[i - 2] !== '\\'); + (i > 1 && str[i - 2] !== '\\'); if (!escaped) { inQuotes = !inQuotes; } diff --git a/package.json b/package.json index 8bee704..5c89bb4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "id": "jsonview@brh.numbera.com", - "version": "1.2.2", + "version": "1.2.3", "name": "jsonview", "title": "JSONView", "description": "View JSON documents in the browser.", diff --git a/tests/issue142.json b/tests/issue142.json new file mode 100644 index 0000000..460d81f --- /dev/null +++ b/tests/issue142.json @@ -0,0 +1 @@ +{"code":0,"message":"OK","result":[{"fund_id":2,"fund_mnemo":"BAIKAL","fund_name":"\u041e\u0410\u041e \u0410\u041a \"\u0411\u0430\u0439\u043a\u0430\u043b\u0411\u0430\u043d\u043a\" ","allow":true,"answer":"\u041d\u0435\u0442 API \u0444\u043e\u043d\u0434\u0430"},{"fund_id":4,"fund_mnemo":null,"fund_name":"\u041f\u0440\u0435\u0437\u0435\u043d\u0442\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u043e\u043d\u0434","allow":true,"answer":"\u041d\u0435\u0442 API \u0444\u043e\u043d\u0434\u0430"}],"cached":false} diff --git a/tests/issue142b.json b/tests/issue142b.json new file mode 100644 index 0000000..b48a1b3 --- /dev/null +++ b/tests/issue142b.json @@ -0,0 +1,4 @@ +{ + "precondition": "text that ends in an escaped backslash \\", + "errorline": "After the number, the parser complains: 3 here is the error" +} diff --git a/tests/issue142c.json b/tests/issue142c.json new file mode 100644 index 0000000..0a74c74 --- /dev/null +++ b/tests/issue142c.json @@ -0,0 +1,3 @@ +{ + "key":"\"value\u201d" +} diff --git a/tests/issue50.json b/tests/issue50.json new file mode 100644 index 0000000..da98d18 --- /dev/null +++ b/tests/issue50.json @@ -0,0 +1 @@ +{"PriorityPointValue":600,"GraphicClickThruUrl":"http://ad.doubleclick.net/clk;279758588;106767756;n","AdditionalUrls":[]}