Bug Tracker

Modify

Ticket #10810 (closed bug: invalid)

Opened 18 months ago

Last modified 18 months ago

$.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:
Blocking: Blocked by:

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.

Change History

comment:1 Changed 18 months ago by phistuck

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.

comment:2 Changed 18 months ago by dmethvin

  • Owner set to phistuck
  • Status changed from new to pending

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?

comment:3 Changed 18 months ago by phistuck

  • Status changed from pending to new

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)...

Last edited 18 months ago by phistuck (previous) (diff)

comment:4 Changed 18 months ago by dmethvin

  • Status changed from new to closed
  • Resolution set to invalid

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

comment:5 Changed 18 months ago by dmethvin

  • Keywords jqueries added
  • Component changed from unfiled to core

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.