Support Regex features: Lookaround, Lookahead and Lookbehind in AutoMod #6860
-
Will these functions be introduced in the automod in the future? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
probably not, considering that adding these features requires switching to a backtracking based regex engine, which in turn introduces the possibility for regex denial of service. you can try it yourself locally in nodejs, which does use backtracking. this regex match will take very long to complete. you can craft an even worse regex & input text combination that will take hours or even days to complete /(a*)*b/.test("a".repeat(2000)) its not possible to reliably detect such denial of service attacks without heavily restricting the options of the regex. but if you limit yourself to only the regular features, without things like lookarounds, you can use a crate like https://github.com/rust-lang/regex (pretty sure this is exactly what discord uses) that always runs in linear time |
Beta Was this translation helpful? Give feedback.
probably not, considering that adding these features requires switching to a backtracking based regex engine, which in turn introduces the possibility for regex denial of service.
you can try it yourself locally in nodejs, which does use backtracking. this regex match will take very long to complete. you can craft an even worse regex & input text combination that will take hours or even days to complete
its not possible to reliably detect such denial of service attacks without heavily restricting the options of the regex.
but if you limit yourself to only the regular features, without things like lookarounds, you can use a crate like https://github.com/rust…