Skip to content

Commit f7edf28

Browse files
committed
allow mailto links in js/unsafe-external-link
1 parent 4e963a8 commit f7edf28

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

javascript/ql/src/DOM/TargetBlank.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ predicate hasDynamicHrefHostAttributeValue(DOM::ElementDefinition elem) {
3131
// fixed string with templating
3232
url.regexpMatch(Templating::getDelimiterMatchingRegexp()) and
3333
// ... that does not start with a fixed host or a relative path (common formats)
34-
not url.regexpMatch("(?i)((https?:)?//)?[-a-z0-9.]*/.*")
34+
not url.regexpMatch("(?i)((https?:)?//)?[-a-z0-9.]*/.*") and
35+
// ... that is not a mailto: link
36+
not url.regexpMatch("mailto:.*")
3537
)
3638
)
3739
}

javascript/ql/test/query-tests/DOM/TargetBlank/tst.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,8 @@ <h1>NOT OK, because of dynamic URL</h1>
2626
Example
2727
</a>
2828

29+
<h1>OK: mailto is fine.</h1>
30+
<a target="_blank" href="mailto:{{var:mail}}">mail somone</a>
31+
2932
</body>
3033
</html>

0 commit comments

Comments
 (0)