File tree 1 file changed +15
-2
lines changed
third-party/projects/jquery-form
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -190,6 +190,15 @@ $.fn.ajaxSubmit = function(options) {
190
190
var oldSuccess = options . success || function ( ) { } ;
191
191
callbacks . push ( function ( data ) {
192
192
var fn = options . replaceTarget ? 'replaceWith' : 'html' ;
193
+
194
+ // Validate `data` through `HTML encoding` when passed
195
+ // `data` is passed to `html()`, as suggested in
196
+ // https://github.com/jquery-form/form/issues/464
197
+
198
+ data = options . replaceTarget
199
+ ? data
200
+ : $ . parseHTML ( $ ( '<div>' ) . text ( data ) . html ( ) ) ;
201
+
193
202
$ ( options . target ) [ fn ] ( data ) . each ( oldSuccess , arguments ) ;
194
203
} ) ;
195
204
}
@@ -801,8 +810,12 @@ $.fn.ajaxSubmit = function(options) {
801
810
return ( doc && doc . documentElement && doc . documentElement . nodeName != 'parsererror' ) ? doc : null ;
802
811
} ;
803
812
var parseJSON = $ . parseJSON || function ( s ) {
804
- /*jslint evil:true */
805
- return window [ 'eval' ] ( '(' + s + ')' ) ;
813
+ // Throw an error instead of making a new function using
814
+ // unsanitized inputs to avoid XSS attacks.
815
+
816
+ window . console . error ( 'jquery.parseJSON is undefined' ) ;
817
+
818
+ return null ;
806
819
} ;
807
820
808
821
var httpData = function ( xhr , type , s ) { // mostly lifted from jq1.4.4
You can’t perform that action at this time.
0 commit comments