Skip to content

Commit 2be5906

Browse files
committed
Fix issue of UTF-8 belows the autolinked email address.
See #388 for more details.
1 parent 7c41cf5 commit 2be5906

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

ext/redcarpet/autolink.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ sd_autolink__email(
224224
for (link_end = 0; link_end < size; ++link_end) {
225225
uint8_t c = data[link_end];
226226

227-
if (isalnum(c))
227+
if (isalnum(c) && c < 0x7f)
228228
continue;
229229

230230
if (c == '@')

test/markdown_test.rb

+6
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ def test_whitespace_after_urls
126126
assert_equal exp, rd
127127
end
128128

129+
def test_auto_linked_email_utf8_issue
130+
rd = render_with({ autolink: true }, "[email protected]\n[email protected]ü")
131+
exp = %{<p><a href="mailto:[email protected]">[email protected]</a>」\n<a href="mailto:[email protected]">[email protected]</a>ü</p>\n}
132+
assert_equal exp, rd
133+
end
134+
129135
def test_memory_leak_when_parsing_char_links
130136
@markdown.render(<<-leaks)
131137
2. Identify the wild-type cluster and determine all clusters

0 commit comments

Comments
 (0)