File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
third-party/projects/jquery-form Expand file tree Collapse file tree 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) {
190190 var oldSuccess = options . success || function ( ) { } ;
191191 callbacks . push ( function ( data ) {
192192 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+
193202 $ ( options . target ) [ fn ] ( data ) . each ( oldSuccess , arguments ) ;
194203 } ) ;
195204 }
@@ -801,8 +810,12 @@ $.fn.ajaxSubmit = function(options) {
801810 return ( doc && doc . documentElement && doc . documentElement . nodeName != 'parsererror' ) ? doc : null ;
802811 } ;
803812 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 ;
806819 } ;
807820
808821 var httpData = function ( xhr , type , s ) { // mostly lifted from jq1.4.4
You can’t perform that action at this time.
0 commit comments