Skip to content

Commit 712c3cc

Browse files
committed
Swift: Add the cases from the (Ruby) qhelp to the library tests.
1 parent 7e9d73b commit 712c3cc

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

swift/ql/test/library-tests/regex/redos_variants.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,9 @@ func myRegexpVariantsTests(myUrl: URL) throws {
4646
_ = try Regex("(a|aa?)b").firstMatch(in: tainted) // $ regex="call to Regex<AnyRegexOutput>.init(_:)" input=tainted
4747
_ = try Regex("(a|aa?)*b").firstMatch(in: tainted) // $ regex="call to Regex<AnyRegexOutput>.init(_:)" input=tainted redos-vulnerable=
4848

49+
// from the qhelp:
50+
_ = try Regex("^_(__|.)+_$").firstMatch(in: tainted) // $ regex="call to Regex<AnyRegexOutput>.init(_:)" input=tainted redos-vulnerable=
51+
_ = try Regex("^_(__|[^_])+_$").firstMatch(in: tainted) // $ regex="call to Regex<AnyRegexOutput>.init(_:)" input=tainted
52+
4953
// TODO: test more variant expressions.
5054
}

0 commit comments

Comments
 (0)