Use getAttribute to safely read attribute value (#110)

This commit is contained in:
Maxim Baz
2019-04-14 23:49:21 +02:00
committed by GitHub
parent da8af0bd11
commit 5a036343d3

View File

@@ -319,10 +319,11 @@
// Try to filter only forms that have some identifying marker // Try to filter only forms that have some identifying marker
const markedForms = []; const markedForms = [];
for (let form of forms) { for (let form of forms) {
const props = [form.id, form.name, form.className, form.action]; const props = ["id", "name", "class", "action"];
for (let marker of FORM_MARKERS) { for (let marker of FORM_MARKERS) {
for (let prop of props) { for (let prop of props) {
if (prop.toLowerCase().indexOf(marker) > -1) { let propValue = form.getAttribute(prop) || "";
if (propValue.toLowerCase().indexOf(marker) > -1) {
markedForms.push(form); markedForms.push(form);
} }
} }