Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

[FIX] XSS validating context and encoding HTML #1

Merged
merged 1 commit into from
Aug 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/jquery.form.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@
var successArguments = arguments,
fn = options.replaceTarget ? 'replaceWith' : 'html';

// Validate `data` through `HTML encoding` when passed `data` is passed
// to `html()`, as suggested in https://github.com/jquery-form/form/issues/464
fn == 'html' ? data = $.parseHTML($("<div>").text(data).html()) : '';

$(options.target)[fn](data).each(function(){
oldSuccess.apply(this, successArguments);
});
Expand Down Expand Up @@ -923,8 +927,12 @@
return (doc && doc.documentElement && doc.documentElement.nodeName !== 'parsererror') ? doc : null;
};
var parseJSON = $.parseJSON || function(s) {
/* jslint evil:true */
return window['eval']('(' + s + ')'); // eslint-disable-line dot-notation

// Arise an error resolvable including jquery instead of
// making a new function using unsanitized inputs

window.console.error('jquery.parseJSON is undefined');
return null;
};

var httpData = function(xhr, type, s) { // mostly lifted from jq1.4.4
Expand Down