Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow setting time limit for regex matching #355

Closed
gagolews opened this issue Jun 28, 2019 · 2 comments
Closed

allow setting time limit for regex matching #355

gagolews opened this issue Jun 28, 2019 · 2 comments

Comments

@gagolews
Copy link
Owner

ICU includes the ability to limit the time spent on a regular expression match. This is a good idea when running untested expressions from users of your application, or as a fail safe for servers or other processes that cannot afford to be hung.

@gagolews
Copy link
Owner Author

virtual void | setTimeLimit (int32_t limit, UErrorCode &status)

@gagolews
Copy link
Owner Author

Done:

gagolews@dionysus:~$ Rscript -e 'stringi::stri_detect_regex("AAAAAAAAAAAAAAAAAAAAAAAAAC", "(A+)+B", time_limit=2)'
Error in stringi::stri_detect_regex("AAAAAAAAAAAAAAAAAAAAAAAAAC", "(A+)+B",  : 
  [!NDEBUG: Error in stri_search_regex_detect.cpp:112] Maximum allowed match time exceeded. (U_REGEX_TIME_OUT)
Execution halted

gagolews@dionysus:~$ Rscript -e 'library(stringi); stri_detect_regex(stri_paste(stri_dup("A", 1000), "C"), "(A+)+B", stack_limit=2048)'
Error in stri_detect_regex(stri_paste(stri_dup("A", 1000), "C"), "(A+)+B",  : 
  [!NDEBUG: Error in stri_search_regex_detect.cpp:112] Regular expression backtrack stack overflow. (U_REGEX_STACK_OVERFLOW)
Execution halted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant