Skip to content

Add tests demonstrating safe-mode unsafe link over-blocking#305

Merged
jgm merged 2 commits into
commonmark:masterfrom
GrahamCampbell:anchor-unsafe-protocol-regex
Jul 12, 2026
Merged

Add tests demonstrating safe-mode unsafe link over-blocking#305
jgm merged 2 commits into
commonmark:masterfrom
GrahamCampbell:anchor-unsafe-protocol-regex

Conversation

@GrahamCampbell

Copy link
Copy Markdown
Contributor

When the safe option is enabled, the ^ anchor in reUnsafeProtocol binds only to the first alternative, so vbscript:, file:, and data: match anywhere in the URL rather than just at the start. Safe links such as https://example.com/view?src=data:image/png are misclassified as unsafe and silently lose their href/src.

The first commit adds tests demonstrating the bug and the second applies the one-line fix.

@jgm jgm merged commit fb7cd84 into commonmark:master Jul 12, 2026
4 checks passed
@jgm

jgm commented Jul 12, 2026

Copy link
Copy Markdown
Member

thanks!

@GrahamCampbell GrahamCampbell deleted the anchor-unsafe-protocol-regex branch July 12, 2026 15:30
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.

2 participants