in reply to Untaint a string match, regular expression.
As a first pass at understanding your concerns, my first thought is to simply ban any regex that contains either of the extended patterns that allow for code execution: (?{...}) and (??{ ... }).
To that end, test if the regex contains either of those patterns:
die "Regex containing code disallowed" if $userRe =~ m[\(\?\??\{];
Combine that with a check that the regex will compile: $userRe = qr[$userRe]; and it's hard to see what input, that passed those two checks, could be dangerous?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Untaint a string match, regular expression.
by Anonymous Monk on May 18, 2015 at 00:16 UTC | |
by BrowserUk (Patriarch) on May 18, 2015 at 00:28 UTC | |
by Anonymous Monk on May 18, 2015 at 00:58 UTC | |
by cheako (Beadle) on May 18, 2015 at 00:43 UTC | |
|
Re^2: Untaint a string match, regular expression.
by cheako (Beadle) on May 18, 2015 at 00:27 UTC | |
by BrowserUk (Patriarch) on May 18, 2015 at 00:29 UTC |