|
10 | 10 | */
|
11 | 11 | /*global ActiveXObject */
|
12 | 12 |
|
13 |
| -// AMD support |
14 | 13 | (function (factory) {
|
15 | 14 | "use strict";
|
16 |
| - if (typeof define === 'function' && define.amd) { |
17 |
| - // using AMD; register as anon module |
18 |
| - define(['jquery'], factory); |
19 |
| - } else { |
20 |
| - // no AMD; invoke directly |
21 |
| - factory( (typeof(jQuery) != 'undefined') ? jQuery : window.Zepto ); |
22 |
| - } |
| 15 | + factory(window.$ || window.Zepto); |
23 | 16 | }
|
24 | 17 |
|
25 | 18 | (function($) {
|
@@ -190,6 +183,15 @@ $.fn.ajaxSubmit = function(options) {
|
190 | 183 | var oldSuccess = options.success || function(){};
|
191 | 184 | callbacks.push(function(data) {
|
192 | 185 | var fn = options.replaceTarget ? 'replaceWith' : 'html';
|
| 186 | + |
| 187 | + // Validate `data` through `HTML encoding` when passed |
| 188 | + // `data` is passed to `html()`, as suggested in |
| 189 | + // https://github.com/jquery-form/form/issues/464 |
| 190 | + |
| 191 | + data = options.replaceTarget |
| 192 | + ? data |
| 193 | + : $.parseHTML($('<div>').text(data).html()); |
| 194 | + |
193 | 195 | $(options.target)[fn](data).each(oldSuccess, arguments);
|
194 | 196 | });
|
195 | 197 | }
|
@@ -801,8 +803,12 @@ $.fn.ajaxSubmit = function(options) {
|
801 | 803 | return (doc && doc.documentElement && doc.documentElement.nodeName != 'parsererror') ? doc : null;
|
802 | 804 | };
|
803 | 805 | var parseJSON = $.parseJSON || function(s) {
|
804 |
| - /*jslint evil:true */ |
805 |
| - return window['eval']('(' + s + ')'); |
| 806 | + // Throw an error instead of making a new function using |
| 807 | + // unsanitized inputs to avoid XSS attacks. |
| 808 | + |
| 809 | + window.console.error('jquery.parseJSON is undefined'); |
| 810 | + |
| 811 | + return null; |
806 | 812 | };
|
807 | 813 |
|
808 | 814 | var httpData = function( xhr, type, s ) { // mostly lifted from jq1.4.4
|
|
0 commit comments