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

Matching filenames can lead to catastrophic backtracking #19

Open
nbargnesi opened this issue May 19, 2017 · 0 comments
Open

Matching filenames can lead to catastrophic backtracking #19

nbargnesi opened this issue May 19, 2017 · 0 comments

Comments

@nbargnesi
Copy link

Similar to #17, matching filenames will result in a lot of backtracking as Python tries to match the .+ in strings without a match.

Here's an example using a large string containing no matches:

import re
test = ('ABCDEF' * 100000)
re.findall("(.+(\.([a-z]{2,3}$)|\/.+\/|\\\.+\\\))+", test)

Matching the max path length on Windows, and putting a 260 character limit in place of the .+ seems a better solution. It will extract filenames and not consume as many cycles when no matches are found.

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