in reply to Re: Is it safe to use external strings for regexes?
in thread Is it safe to use external strings for regexes?
In the latter case, there are three issues I'm aware ofString interpolation of variables only happens for literal regexes in the source code. So if the pattern is read from a file or database this isn't an issue.
- code injection by string interpolation, like /@{ do_evil() }/
- code injection by regex, like /(?{ do_evil() })/
- exponential time regexes with excessive backtracking, something like /((x*)*)*/ IIRC </ol?
Embedded code within a pattern is only allowed within the scope of use re 'eval'; otherwise trying to compile such a regex from a string will die at run time.
The third one is a genuine issue, in terms of both CPU and memory usage.
Dave.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Is it safe to use external strings for regexes?
by LanX (Sage) on Oct 07, 2021 at 13:38 UTC | |
by dave_the_m (Monsignor) on Oct 07, 2021 at 15:26 UTC | |
by LanX (Sage) on Oct 07, 2021 at 20:50 UTC | |
by dave_the_m (Monsignor) on Oct 08, 2021 at 07:01 UTC | |
by LanX (Sage) on Oct 08, 2021 at 10:01 UTC |
In Section
Seekers of Perl Wisdom