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

Catastrophic backtracking #82

Open
bytestream opened this issue Jul 15, 2024 · 1 comment
Open

Catastrophic backtracking #82

bytestream opened this issue Jul 15, 2024 · 1 comment
Milestone

Comments

@bytestream
Copy link
Contributor

The comment regex in https://github.com/xemlock/htmlpurifier-html5/blob/master/library/HTMLPurifier/Lexer/HTML5.php#L57 can cause catastrophic back tracking. The result is preg_replace_callback returns null

Workaround is to increase pcre.backtrack_limit. However, I think it would be better if the error handling in this function is improved to account for when preg_replace_callback returns null. I expect that it would just skip that comment regex functionality in that case.

@bytestream
Copy link
Contributor Author

Changing the regex to <!--([^>]*)(-->|\z) also fixes the back tracking issue.

@xemlock xemlock added this to the 0.1.12 milestone Sep 1, 2024
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

2 participants