Skip to content

Commit 0a29d13

Browse files
committed
reuse existing logic in DomBasedXss
1 parent a5bbfa3 commit 0a29d13

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

javascript/ql/src/semmle/javascript/security/dataflow/XssThroughDom.qll

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,14 @@ module XssThroughDom {
6262
this.getArgument(0).mayHaveStringValue(unsafeAttributeName())
6363
) and
6464
// looks like a $("<p>" + ... ) source, which is benign for this query.
65-
not this
66-
.getReceiver()
67-
.(DataFlow::CallNode)
68-
.getAnArgument()
69-
.(StringOps::ConcatenationRoot)
70-
.getConstantStringParts()
71-
.substring(0, 1) = "<"
65+
not exists(DataFlow::Node prefix |
66+
DomBasedXss::isPrefixOfJQueryHtmlString(this
67+
.getReceiver()
68+
.(DataFlow::CallNode)
69+
.getAnArgument(), prefix)
70+
|
71+
prefix.getStringValue().regexpMatch("\\s*<.*")
72+
)
7273
}
7374
}
7475

0 commit comments

Comments
 (0)