Merge pull request #5236 from asgerf/js/html-invalid-attr-name

Approved by erik-krogh
This commit is contained in:
CodeQL CI
2021-02-23 02:03:29 -08:00
committed by GitHub
2 changed files with 16 additions and 0 deletions

View File

@@ -143,6 +143,18 @@ public class HTMLExtractor implements IExtractor {
}
}
}
@Override
public boolean shouldExtractAttributes(Element element) {
Attributes attributes = element.getAttributes();
if (attributes == null) return false;
for (Attribute attr : attributes) {
if (!VALID_ATTRIBUTE_NAME.matcher(attr.getName()).matches()) {
return false;
}
}
return true;
}
}
private boolean isAngularTemplateAttributeName(String name) {
@@ -153,6 +165,8 @@ public class HTMLExtractor implements IExtractor {
private static final Pattern ANGULAR_FOR_LOOP_DECL = Pattern.compile("^ *let +(\\w+) +of(?: +|(?!\\w))(.*)");
private static final Pattern VALID_ATTRIBUTE_NAME = Pattern.compile("\\*?\\[?\\(?[\\w:_\\-]+\\]?\\)?");
/** List of HTML attributes whose value is interpreted as JavaScript. */
private static final Pattern JS_ATTRIBUTE =
Pattern.compile(

View File

@@ -1 +1,3 @@
<a href="https://semmle.com" href="https://semmle.com">Semmle</a>
<td {% foo %} {% foo %}></td>