From 2be5906b9240a0dace2ba582dd7eccf0a8e7bc92 Mon Sep 17 00:00:00 2001 From: David Kuo Date: Sat, 7 Feb 2015 22:26:32 +0800 Subject: [PATCH] Fix issue of UTF-8 belows the autolinked email address. See https://github.com/vmg/redcarpet/issues/388 for more details. --- ext/redcarpet/autolink.c | 2 +- test/markdown_test.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ext/redcarpet/autolink.c b/ext/redcarpet/autolink.c index ce7156d1..f551ab97 100644 --- a/ext/redcarpet/autolink.c +++ b/ext/redcarpet/autolink.c @@ -224,7 +224,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 aab3e398..259fc3a8 100644 --- a/test/markdown_test.rb +++ b/test/markdown_test.rb @@ -126,6 +126,12 @@ def test_whitespace_after_urls assert_equal exp, rd 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 @markdown.render(<<-leaks) 2. Identify the wild-type cluster and determine all clusters