1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-06 21:45:45 +01:00

Ignore unnamed and disabled fields in util.parseForm. Closes issue #564.

This commit is contained in:
Kris Maglione
2011-07-27 09:27:59 -04:00
parent c80ac6e2af
commit f220206df5

View File

@@ -1481,17 +1481,20 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
if (field instanceof Ci.nsIDOMHTMLInputElement && field.type == "submit")
elems.push(encode(field.name, field.value));
for (let [, elem] in iter(form.elements)) {
if (Set.has(util.editableInputs, elem.type)
|| /^(?:hidden|textarea)$/.test(elem.type)
|| elem.checked && /^(?:checkbox|radio)$/.test(elem.type))
elems.push(encode(elem.name, elem.value, elem === field));
else if (elem instanceof Ci.nsIDOMHTMLSelectElement) {
for (let [, opt] in Iterator(elem.options))
if (opt.selected)
elems.push(encode(elem.name, opt.value));
for (let [, elem] in iter(form.elements))
if (elem.name && !elem.disabled) {
if (Set.has(util.editableInputs, elem.type)
|| /^(?:hidden|textarea)$/.test(elem.type)
|| elem.type == "submit" && elem == field
|| elem.checked && /^(?:checkbox|radio)$/.test(elem.type))
elems.push(encode(elem.name, elem.value, elem === field));
else if (elem instanceof Ci.nsIDOMHTMLSelectElement) {
for (let [, opt] in Iterator(elem.options))
if (opt.selected)
elems.push(encode(elem.name, opt.value));
}
}
}
if (post)
return [url, elems.join('&'), charset, elems];
return [url + "?" + elems.join('&'), null, charset, elems];