Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion markdown_it/rules_inline/linkify.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
from .state_inline import StateInline

# RFC3986: scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
SCHEME_RE = re.compile(r"(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$", re.IGNORECASE)
SCHEME_RE = re.compile(
r"(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$", re.IGNORECASE | re.ASCII
)


def linkify(state: StateInline, silent: bool) -> bool:
Expand Down
9 changes: 9 additions & 0 deletions tests/test_linkify.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,12 @@ def test_token_levels():
assert link_open.level == 0
assert link_text.level == 1
assert link_close.level == 0


@pytest.mark.parametrize("prefix", ["\N{LATIN SMALL LETTER LONG S}", "\N{KELVIN SIGN}"])
def test_linkify_scheme_is_ascii_only(prefix):
"""Letters that case-fold to ASCII are not scheme characters."""
mdit = MarkdownIt(options_update={"linkify": True}).enable("linkify")
assert mdit.render(f"{prefix}http://example.com") == (
f'<p>{prefix}<a href="http://example.com">http://example.com</a></p>\n'
)