From c19be7d8adc0f214048e8aaf5cd583ec249a53c1 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 13 Nov 2009 07:06:14 +0000 Subject: [PATCH] Copy in json.org unserialize() so JSON.parse() works in Fx3 --- translators/ARTstor.js | 19 ++++++++++++++++++- ...onal Library of Australia (new catalog).js | 19 ++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/translators/ARTstor.js b/translators/ARTstor.js index a5dc5babc2..0af9de96c0 100644 --- a/translators/ARTstor.js +++ b/translators/ARTstor.js @@ -8,7 +8,7 @@ "maxVersion":"", "priority":100, "inRepository":true, - "lastUpdated":"2009-11-13 04:15:00" + "lastUpdated":"2009-11-13 07:10:00" } function detectWeb(doc, url) { @@ -21,6 +21,23 @@ function doWeb(doc, url) { } } +// TODO: Remove this when we drop support for Fx3 +if (!JSON) { + var JSON = new function() { + this.parse = function (arg) { + var j; + if (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/.test(arg. + replace(/\\./g, '@'). + replace(/"[^"\\\n\r]*"/g, ''))) { + // Friendly AMO reviewer: This is the official json.org library and is safe. + j = eval('(' + arg + ')'); + return j; + } + throw new SyntaxError('parseJSON'); + } + } +} + function scrape(doc, url){ var savedItems = new Array(); var saved = 0; diff --git a/translators/National Library of Australia (new catalog).js b/translators/National Library of Australia (new catalog).js index bd627d4068..b3f77fc064 100644 --- a/translators/National Library of Australia (new catalog).js +++ b/translators/National Library of Australia (new catalog).js @@ -8,7 +8,7 @@ "maxVersion":"", "priority":100, "inRepository":true, - "lastUpdated":"2009-11-13 04:15:00" + "lastUpdated":"2009-11-13 07:10:00" } function detectWeb(doc, url) { @@ -59,6 +59,23 @@ function computeFormat(format){ } +// TODO: Remove this when we drop support for Fx3 +if (!JSON) { + var JSON = new function() { + this.parse = function (arg) { + var j; + if (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/.test(arg. + replace(/\\./g, '@'). + replace(/"[^"\\\n\r]*"/g, ''))) { + // Friendly AMO reviewer: This is the official json.org library and is safe. + j = eval('(' + arg + ')'); + return j; + } + throw new SyntaxError('parseJSON'); + } + } +} + function load_item(responseText, url, format) { var metadata = JSON.parse(Zotero.Utilities.trimInternal(responseText)); var bibid = url.match("^.*\/Record/([0-9]+)")[1];