Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is RegEx from user input safe?

I'm working on an app that needs to accept a RegEx from the user, to do so I'm using the following code:

Regex user_searchPattern = new Regex(this.userInput_regEx.Text);

Is doing this safe?
Is there a need to sanitize the user input, and if so how?

like image 457
UnkwnTech Avatar asked Dec 31 '22 00:12

UnkwnTech


1 Answers

You might get an error if the regular expression has an invalid syntax or it might consume a exponential amount of time and space when processed if a so-called pathological regular expression is tested on some particular string.

like image 56
Gumbo Avatar answered Jan 11 '23 22:01

Gumbo