Sanitization of User-Supplied Regular Expressions in PHP

前端 未结 5 867
盖世英雄少女心
盖世英雄少女心 2020-12-20 21:03

I want to create a website where users can test regular expressions (there are many out there already...such as this one: http://www.pagecolumn.com/tool/pregtest.htm). Basic

5条回答
  •  一个人的身影
    2020-12-20 21:54

    Afaik there are now "vulnerabilities" when trying to evaluate user-supplied regexps. The worst thing that could possibly happen is - like erik points out - a DOS attack or fatal error within your script.

    I'm afraid to tell you that you won't be (even theoretically) able to "sanitize" every possible regexp out there. The best you can do is to check for lexical and/or syntactic errors.

提交回复
热议问题