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

Expressions with the * operator runs infinitely #27

Open
jack0lantern opened this issue Jul 31, 2015 · 4 comments
Open

Expressions with the * operator runs infinitely #27

jack0lantern opened this issue Jul 31, 2015 · 4 comments

Comments

@jack0lantern
Copy link

On this page:
http://docs.oracle.com/javase/tutorial/essential/concurrency/procthread.html

I searched s* and it appears to enter an infinite loop in v 1.8. Eventually, the page crashes.

@gsingh93
Copy link
Owner

Whoa... well this is bad. I'm not sure what the proper fix is for this or when I'll get time to look into it, but thanks for the report.

@ComFreek
Copy link
Contributor

I can confirm this.

Please use s+ (at least one s) instead. It is more efficient than s* (0 or more s) because the latter even matches empty strings all over the page.

@gsingh93
Copy link
Owner

Maybe we should disallow searching any two character regex where the second character is a '', or the one character regex where '' is the only character. Does that cover all of the bad cases or are there other cases we're missing?

@ComFreek
Copy link
Contributor

Some test cases performed on the website mentioned in the first comment:

1 works:         .*
2 works:         ..........
3 works:         .*.*.*.*.*.*.*
4 works:         (.+)*
5 fails:            s*

It seems that some optimization is done in case 1 as opposed to case 5.

So indeed, it might be a good idea to disallow a regex consisting of any character followed by * only.
Or shall we rather add general hint/warning that usage of '+' is encouraged contrary to '*'

PS: You can escape asterisks and other Markdown syntax by a backslash: \ *

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

3 participants