From 53fb4438190b3e3c3a62518c98d575752a653fa2 Mon Sep 17 00:00:00 2001 From: crschmidt Date: Mon, 7 Apr 2008 04:22:35 +0000 Subject: [PATCH] Replace the regular expression used in Format.JSON with one which is longer, but apparently more friendly to braindead browsers. This allows Safari 3.1 to parse long JSON strings (>26k), which was not possible with the previous regex. r=euzuro (Pullup #1493) git-svn-id: http://svn.openlayers.org/trunk/openlayers@6801 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Format/JSON.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Format/JSON.js b/lib/OpenLayers/Format/JSON.js index a61ecdb179..d15a713472 100644 --- a/lib/OpenLayers/Format/JSON.js +++ b/lib/OpenLayers/Format/JSON.js @@ -95,8 +95,9 @@ OpenLayers.Format.JSON = OpenLayers.Class(OpenLayers.Format, { * characters. */ try { - if(/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/. - test(json)) { + if (/^[\],:{}\s]*$/.test(json.replace(/\\["\\\/bfnrtu]/g, '@'). + replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']'). + replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { /** * In the second stage we use the eval function to compile the