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

AsciiDoc: Some regexes are too greedy #3481

Merged
merged 1 commit into from Jun 25, 2022

Conversation

RunDevelopment
Copy link
Member

Fixes #3480.

We had a few regexes of the form /^(some prefix)(?:\r?\n|\r)(?:[\s\S]*(?:\r?\n|\r))??\1$/m. This is incorrect as the greedy [\s\S]* will overrun all occurrences of the captured prefix until the last occurrence is found. I replaced it with /^(some prefix)$[\s\S]*?^\1$/m.

@github-actions
Copy link

JS File Size Changes (gzipped)

A total of 1 files have changed, with a combined diff of -10 B (-0.6%).

file master pull size diff % diff
components/prism-asciidoc.min.js 1.62 KB 1.61 KB -10 B -0.6%

Generated by 🚫 dangerJS against 3c772e0

Copy link
Collaborator

@JaKXz JaKXz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! My only nit would be to break up the large test file for readability but that's not a blocker.

@RunDevelopment
Copy link
Member Author

My only nit would be to break up the large test file for readability but that's not a blocker.

I see what you mean, but that was intentional. Regexes that are too greedy might come up again, and long test snippets are more likely to include examples that trigger these bugs.

@RunDevelopment RunDevelopment merged commit c4cbeea into PrismJS:master Jun 25, 2022
@RunDevelopment RunDevelopment deleted the issue3480 branch June 25, 2022 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Asciidoc processing fails on [source]
2 participants