Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue of UTF-8 belows the autolinked email address. #463

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/redcarpet/autolink.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ sd_autolink__email(
for (link_end = 0; link_end < size; ++link_end) {
uint8_t c = data[link_end];

if (isalnum(c))
if (isalnum(c) && c < 0x7f)
continue;

if (c == '@')
Expand Down
6 changes: 6 additions & 0 deletions test/markdown_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ def test_whitespace_after_urls
assert_equal expected, output
end

def test_auto_linked_email_utf8_issue
output = render("a@b.c」\nd@example.coü", with: [:autolink])
expected = %{<p><a href="mailto:a@b.c">a@b.c</a>」\n<a href="mailto:d@example.co">d@example.co</a>ü</p>\n}
assert_equal expected, output
end

def test_memory_leak_when_parsing_char_links
render(<<-leaks.strip_heredoc)
2. Identify the wild-type cluster and determine all clusters
Expand Down