зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1365542 - Use HTML5 FormData object rather than hand-rolling form data for search keyword handling r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D14877 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
ebf73ac0ad
Коммит
eede68dc61
|
@ -125,41 +125,18 @@ const messageListeners = {
|
||||||
(node.form.enctype == "application/x-www-form-urlencoded" ||
|
(node.form.enctype == "application/x-www-form-urlencoded" ||
|
||||||
node.form.enctype == ""));
|
node.form.enctype == ""));
|
||||||
let title = node.ownerDocument.title;
|
let title = node.ownerDocument.title;
|
||||||
let formData = [];
|
|
||||||
|
|
||||||
function escapeNameValuePair(aName, aValue, aIsFormUrlEncoded) {
|
function escapeNameValuePair([aName, aValue]) {
|
||||||
if (aIsFormUrlEncoded) {
|
if (isURLEncoded) {
|
||||||
return escape(aName + "=" + aValue);
|
return escape(aName + "=" + aValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
return escape(aName) + "=" + escape(aValue);
|
return escape(aName) + "=" + escape(aValue);
|
||||||
}
|
}
|
||||||
|
let formData = new this.content.FormData(node.form);
|
||||||
for (let el of node.form.elements) {
|
formData.delete(node.name);
|
||||||
if (!el.type) // happens with fieldsets
|
formData = Array.from(formData).map(escapeNameValuePair);
|
||||||
continue;
|
formData.push(escape(node.name) + (isURLEncoded ? escape("=%s") : "=%s"));
|
||||||
|
|
||||||
if (el == node) {
|
|
||||||
formData.push((isURLEncoded) ? escapeNameValuePair(el.name, "%s", true) :
|
|
||||||
// Don't escape "%s", just append
|
|
||||||
escapeNameValuePair(el.name, "", false) + "%s");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let type = el.type.toLowerCase();
|
|
||||||
|
|
||||||
if (((el instanceof this.content.HTMLInputElement && el.mozIsTextField(true)) ||
|
|
||||||
type == "hidden" || type == "textarea") ||
|
|
||||||
((type == "checkbox" || type == "radio") && el.checked)) {
|
|
||||||
formData.push(escapeNameValuePair(el.name, el.value, isURLEncoded));
|
|
||||||
} else if (el instanceof this.content.HTMLSelectElement && el.selectedIndex >= 0) {
|
|
||||||
for (let j = 0; j < el.options.length; j++) {
|
|
||||||
if (el.options[j].selected)
|
|
||||||
formData.push(escapeNameValuePair(el.name, el.options[j].value,
|
|
||||||
isURLEncoded));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let postData;
|
let postData;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче