OpenLayers OpenLayers

Ticket #1493 (closed bug: fixed)

Opened 8 months ago

Last modified 8 months ago

Update JSON Format Regex to match json.org

Reported by: crschmidt Assigned to: tschaub
Priority: minor Milestone: 2.6 Release
Component: Format.GeoJSON Version: 2.6 RC1
Keywords: Cc:
State: Complete

Description

JSON.org has an updated regex in their json.js since we wrote Format.JSON: it is described as such:

// We split the first stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace all backslash pairs with '@' (a non-JSON character). Second, we
// replace all simple value tokens with ']' characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or ']' or
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.

I ran into a regression that essentially means no large GeoJSON strings can be used in Safari 3.1: I filed a ticket in their bug tracker (http://bugs.webkit.org/show_bug.cgi?id=18327), but instead of waiting for a fix there, we can just improve Format.JSON.

I have confirmed that this works, and that all Format.JSON tests continue to pass in Safari, Opera, Firefox, and IE. (We don't have any tests over 25000 characters at this time, so we never actually failed tests in Safari 3.1, just real usage.)

Since this change in Safari 3.1 essentially makes GeoJSON unusable for most purposes, I'd like to consider this a blocker for RC2.

Attachments

json.patch (0.7 kB) - added by crschmidt on 04/05/08 22:00:37.

Change History

04/05/08 22:00:37 changed by crschmidt

  • attachment json.patch added.

04/05/08 22:00:53 changed by crschmidt

  • state set to Review.

04/05/08 22:01:15 changed by crschmidt

JSON.org json.js: http://json.org/json.js

04/07/08 00:20:31 changed by euzuro

  • state changed from Review to Commit.

well chief, if all tests pass and it comes from upstream, no reason to say no.

good work on this.

/me perks nose, smells waft of rc2

04/07/08 00:22:35 changed by crschmidt

  • keywords set to pullup.
  • state changed from Commit to Pullup.

(In [6801]) 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)

04/07/08 21:51:04 changed by crschmidt

  • keywords deleted.
  • status changed from new to closed.
  • state changed from Pullup to Complete.
  • resolution set to fixed.

(In [6819]) Pullup commits from trunk to 2.6 branch:

  • virtualStyle typo (Closes #1495)
  • JSON fix for Safari 3.1 (Closes #1493)
  • panzoombar off-by-one (Closes #1486)
  • Handler Hover exception (Closes #1480)
  • Popup.framedcloud exception (Closes #1479)
  • VML Renderer when including namespace in page (Closes #1477)
  • SLD/Rule/Filter changes -- most of this commit (Closes #1492)