[OpenLayers-Commits] r6801 - trunk/openlayers/lib/OpenLayers/Format

commits at openlayers.org commits at openlayers.org
Mon Apr 7 00:22:35 EDT 2008


Author: crschmidt
Date: 2008-04-07 00:22:35 -0400 (Mon, 07 Apr 2008)
New Revision: 6801

Modified:
   trunk/openlayers/lib/OpenLayers/Format/JSON.js
Log:
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)


Modified: trunk/openlayers/lib/OpenLayers/Format/JSON.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Format/JSON.js	2008-04-07 04:09:46 UTC (rev 6800)
+++ trunk/openlayers/lib/OpenLayers/Format/JSON.js	2008-04-07 04:22:35 UTC (rev 6801)
@@ -95,8 +95,9 @@
          *     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



More information about the Commits mailing list