Skip to content

Commit a8e11fe

Browse files
author
Norbert Nemeth
committed
LPS-125854 Fix XSS validating context and encoding HTML
1 parent 9abb541 commit a8e11fe

File tree

1 file changed

+11
-2
lines changed
  • modules/apps/frontend-js/frontend-js-jquery-web/src/main/resources/META-INF/resources/jquery

1 file changed

+11
-2
lines changed

modules/apps/frontend-js/frontend-js-jquery-web/src/main/resources/META-INF/resources/jquery/form.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,11 @@
243243
var oldSuccess = options.success || function () {};
244244
callbacks.push(function (data) {
245245
var fn = options.replaceTarget ? 'replaceWith' : 'html';
246+
247+
// Validate `data` through `HTML encoding` when passed `data` is passed
248+
// to `html()`, as suggested in https://github.com/jquery-form/form/issues/464
249+
fn == 'html' ? data = $.parseHTML($("<div>").text(data).html()) : '';
250+
246251
$(options.target)[fn](data).each(oldSuccess, arguments);
247252
});
248253
}
@@ -1076,8 +1081,12 @@
10761081
var parseJSON =
10771082
$.parseJSON ||
10781083
function (s) {
1079-
/*jslint evil:true */
1080-
return window['eval']('(' + s + ')');
1084+
1085+
// Arise an error resolvable including jquery instead of
1086+
// making a new function using unsanitized inputs
1087+
1088+
window.console.error('jquery.parseJSON is undefined');
1089+
return null;
10811090
};
10821091

10831092
var httpData = function (xhr, type, s) {

0 commit comments

Comments
 (0)