fix: skip regex checks on autolink URLs - #152
Open
Kubudak90 wants to merge 1 commit into
Open
Conversation
Autolinks like <https://example.com/eip7002> have their URL text incorrectly checked against regex patterns. This causes false positives when URLs contain prohibited patterns. The fix uses a stack-based approach: - Push link URL onto stack when entering a link - When entering text, if text equals the top URL, it's an autolink - skip it - Pop URL from stack when departing the link This correctly handles nested links and distinguishes between: - Autolinks: <url> - URL text is not checked - Regular links: [text](url) - link text is checked Fixes ethereum#91
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #91.
Autolinks like
<https://example.com/eip7002>have their URL text incorrectly checked against regex patterns, causing false positives when URLs contain prohibited patterns (e.g.eip7002matching themarkdown-re-eip-dashregex).Root Cause
The visitor pattern traverses all text nodes, including those inside autolinks. For autolinks, the URL itself becomes the text content and gets checked by
enter_text, which shouldn't happen.Solution
Use a stack-based approach to track link URLs:
This correctly handles:
<url>— URL text is not checked[text](url)— link text is still checkedTesting
All existing tests pass, plus new tests verify: