diff --git a/ext/redcarpet/autolink.c b/ext/redcarpet/autolink.c index 03b7bcea..e34ae59b 100644 --- a/ext/redcarpet/autolink.c +++ b/ext/redcarpet/autolink.c @@ -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 == '@') diff --git a/test/markdown_test.rb b/test/markdown_test.rb index 1069c596..33f6aec7 100644 --- a/test/markdown_test.rb +++ b/test/markdown_test.rb @@ -149,6 +149,12 @@ def test_whitespace_after_urls assert_equal expected, output end + def test_auto_linked_email_utf8_issue + rd = render_with({ autolink: true }, "a@b.c」\nd@example.coü") + exp = %{

a@b.c」\nd@example.coü

\n} + assert_equal exp, rd + end + def test_memory_leak_when_parsing_char_links render(<<-leaks.strip_heredoc) 2. Identify the wild-type cluster and determine all clusters