Skip to content

URL-encode link-patterns destinations - #749

Open
Don-Yin wants to merge 2 commits into
trentm:masterfrom
Don-Yin:fix-link-pattern-url-encoding
Open

Don-Yin wants to merge 2 commits into
trentm:masterfrom
Don-Yin:fix-link-pattern-url-encoding

Conversation

@Don-Yin

@Don-Yin Don-Yin commented Oct 26, 2026

Copy link
Copy Markdown

Fixes #55.

link-patterns wrote the generated destination into href as is, so a pattern producing a target with spaces gave href="lorem foo bar ipsum". I URL-encode it with urllib.parse.quote, keeping URL delimiters and existing % escapes, so normal URLs come out unchanged.

repro on master and with this change

I added a test for the case in the issue. The full test suite and make testredos pass locally.

Fixes trentm#55

Signed-off-by: Don Yin <Don_Yin@outlook.com>
Signed-off-by: Don Yin <Don_Yin@outlook.com>
Comment thread test/test_markdown2.py
Python-markdown (markdown.py).
"""

def test_link_pattern_url_encoding(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should go as a test file in test/tm-cases. Better error formatting

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.

properly URL-encode href attributes

2 participants