From de152594c9fdfa3479b18ce8f253890f1dc255dd Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Sat, 7 Jan 2017 18:19:13 -0800 Subject: [PATCH] Tweak quote finder regex to fix #138. --- CHANGELOG.md | 4 ++++ lib/jsonview.js | 2 +- package.json | 2 +- tests/issue138.json | 3 +++ tests/issue21b.json | 6 ++++++ tests/issue21c.json | 3 +++ 6 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 tests/issue138.json create mode 100644 tests/issue21b.json create mode 100644 tests/issue21c.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b45bc4..7de1de6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +JSONView 1.2.1 +--- +* Fixed a case where JSON would fail to parse if a string contains a number and the JSON isn't indented. + JSONView 1.2.0 --- * Add a preference to use the built-in Firefox JSON viewer. diff --git a/lib/jsonview.js b/lib/jsonview.js index 04bfad5..059760b 100644 --- a/lib/jsonview.js +++ b/lib/jsonview.js @@ -97,7 +97,7 @@ var JSONView = Class({ // Find unescaped quotes by searching for a non-backslash followed by 0 or even // pairs of backslashes, then a quote - var quoteFinder = /([^\\]|^)(\\\\)*(?=")/gm; + var quoteFinder = /[^\\\n\r]*?(\\\\)*"/gm; // This has some memory of what its last state was var wasInQuotes = false; diff --git a/package.json b/package.json index 8d6c8c8..5c0b20f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "id": "jsonview@brh.numbera.com", - "version": "1.2.0", + "version": "1.2.1", "name": "jsonview", "title": "JSONView", "description": "View JSON documents in the browser.", diff --git a/tests/issue138.json b/tests/issue138.json new file mode 100644 index 0000000..8c90463 --- /dev/null +++ b/tests/issue138.json @@ -0,0 +1,3 @@ +{ +"i18n":"label" +} diff --git a/tests/issue21b.json b/tests/issue21b.json new file mode 100644 index 0000000..24e73dd --- /dev/null +++ b/tests/issue21b.json @@ -0,0 +1,6 @@ +{ + "tags": [ + "" + ], + "id-shouldEndWith664": 336541846568177664 + } diff --git a/tests/issue21c.json b/tests/issue21c.json new file mode 100644 index 0000000..9ca042c --- /dev/null +++ b/tests/issue21c.json @@ -0,0 +1,3 @@ +{ +"":"18" +}