File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -480,6 +480,9 @@ jQuery.extend({
480480 if ( typeof data !== "string" || ! data ) {
481481 return null ;
482482 }
483+
484+ // Make sure leading/trailing whitespace is removed (IE can't handle it)
485+ data = jQuery . trim ( data ) ;
483486
484487 // Make sure the incoming data is actual JSON
485488 // Logic borrowed from http://json.org/json2.js
Original file line number Diff line number Diff line change @@ -807,14 +807,16 @@ test("jQuery.proxy", function(){
807807} ) ;
808808
809809test ( "jQuery.parseJSON" , function ( ) {
810- expect ( 7 ) ;
810+ expect ( 8 ) ;
811811
812812 equals ( jQuery . parseJSON ( ) , null , "Nothing in, null out." ) ;
813813 equals ( jQuery . parseJSON ( null ) , null , "Nothing in, null out." ) ;
814814 equals ( jQuery . parseJSON ( "" ) , null , "Nothing in, null out." ) ;
815815
816816 same ( jQuery . parseJSON ( "{}" ) , { } , "Plain object parsing." ) ;
817817 same ( jQuery . parseJSON ( '{"test":1}' ) , { "test" :1 } , "Plain object parsing." ) ;
818+
819+ same ( jQuery . parseJSON ( '\n{"test":1}' ) , { "test" :1 } , "Make sure leading whitespaces are handled." ) ;
818820
819821 try {
820822 jQuery . parseJSON ( "{a:1}" ) ;
@@ -829,4 +831,4 @@ test("jQuery.parseJSON", function(){
829831 } catch ( e ) {
830832 ok ( true , "Test malformed JSON string." ) ;
831833 }
832- } ) ;
834+ } ) ;
You can’t perform that action at this time.
0 commit comments