Skip to main content

Bug Tracker

Side navigation

#10810 closed bug (invalid)

Opened November 17, 2011 07:27AM UTC

Closed November 18, 2011 03:21PM UTC

Last modified November 18, 2011 03:34PM UTC

$.parseJSON("null") Causes Stack Overflow With Internet Explorer 6 - 7

Reported by: phistuck Owned by: phistuck
Priority: undecided Milestone: None
Component: core Version: 1.7
Keywords: jqueries Cc:
Blocked by: Blocking:
Description

In all of the (modern) browsers, JSON.parse returns null when called with JSON.parse("null"), so $.parseJSON should do the same for browsers with no native JSON support.

Tested and failed with jQuery 1.7, jQuery 1.6.4, jQuery 1.5.1.

Attachments (0)
Change History (5)

Changed November 17, 2011 07:28AM UTC by phistuck comment:1

I neglected to mention that in some configurations, this causes Internet Explorer 6 to simply shut down immediately, without any warning.

Other times, it just shows a weird stack overflow alert and the rest of the page keeps loading as usual.

Changed November 17, 2011 01:22PM UTC by dmethvin comment:2

owner: → phistuck
status: newpending

This works fine for me in IE7: http://jsfiddle.net/dmethvin/eUQVX/

Is it possible you are including some other code that is shimming JSON.parse?

Changed November 18, 2011 02:24PM UTC by phistuck comment:3

_comment0: Oh. Actually, now that you have mentioned it... \ I include something like that (after jQuery is loaded, but before I use JSON.parse) - \ if (!window.JSON) \ { \ window.JSON = {parse: $.parseJSON}; \ } \ Can you maybe add a check for that (JSON.parse !== $.parseJSON) in jQuery? \ I prefer to use JSON.parse straight on instead of $.parseJSON every time)...1321626326181907
_comment1: Oh. Actually, now that you have mentioned it... \ I include something like that (after jQuery is loaded, but before I use {{{JSON.parse}}}) - \ {{{ \ if (!window.JSON) \ { \ window.JSON = {parse: $.parseJSON}; \ } \ }}} \ Can you maybe add a check for that ({{{JSON.parse !== $.parseJSON}}}) in jQuery? \ I prefer to use {{{JSON.parse}}} straight on instead of {{{$.parseJSON}}} every time)...1321626389342683
status: pendingnew

Oh. Actually, now that you have mentioned it...

I include something like that (after jQuery is loaded, but before I use

JSON.parse
) -

if (!window.JSON)
{
 window.JSON = {parse: $.parseJSON};
}

Can you maybe add a check for that (

JSON.parse !== $.parseJSON
) in jQuery?

I prefer to use

JSON.parse
straight on instead of
$.parseJSON
every time)...

Changed November 18, 2011 03:21PM UTC by dmethvin comment:4

resolution: → invalid
status: newclosed

No. Don't replace native methods with semi-functional ones, it will confuse code that expects things to work.

Changed November 18, 2011 03:34PM UTC by dmethvin comment:5

component: unfiledcore
keywords: → jqueries