Skip to content

fix: skip regex checks on autolink URLs - #145

Closed
Kubudak90 wants to merge 1 commit into
ethereum:masterfrom
Kubudak90:fix/regex-autolink-clean
Closed

fix: skip regex checks on autolink URLs#145
Kubudak90 wants to merge 1 commit into
ethereum:masterfrom
Kubudak90:fix/regex-autolink-clean

Conversation

@Kubudak90

Copy link
Copy Markdown

Fixes #91.

Autolinks like \u003chttps://example.com/eip7002\u003e were incorrectly checked against regex patterns, causing false positives when URLs contained prohibited patterns.

Root Cause

The visitor traverses all text nodes, including autolink URL text, which shouldn't be checked against regex patterns.

Solution

Use a link URL stack to track when we're inside a link:

  1. pushes the link URL onto the stack
  2. checks if text matches the top URL — if so, it's an autolink and we skip the pattern check
  3. pops the URL from the stack

This correctly handles:

  • Autolinks: \u003curl\u003e — URL text is not checked
  • Regular links: text — link text is still properly checked
  • Nested links: stack handles nesting correctly

Changes

  • : add stack-based autolink detection
  • : regression tests

All existing tests pass.

Fixes ethereum#91.

Autolinks like \u003chttps://example.com/eip7002\u003e were incorrectly
checked against regex patterns, causing false positives when URLs
contained prohibited patterns.

Root cause: the visitor traverses all text nodes, including autolink
URL text, which shouldn't be checked.

Solution: use a link URL stack to track when we're inside a link.
When enter_text sees text matching the top URL on the stack, it's
an autolink and we skip the pattern check. This correctly handles:
- Autolinks: URL text is not checked
- Regular links: [text](url) - link text is still checked
- Nested links: stack handles nesting correctly
@Kubudak90

Copy link
Copy Markdown
Author

Closing in favor of #152 which has the same fix with a cleaner commit history.

@Kubudak90 Kubudak90 closed this Apr 13, 2026
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

Successfully merging this pull request may close these issues.

1 participant