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 www link and url link. #464

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
4 changes: 2 additions & 2 deletions ext/redcarpet/autolink.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ sd_autolink__www(
if (link_end == 0)
return 0;

while (link_end < size && !isspace(data[link_end]))
while (link_end < size && (!isspace(data[link_end]) || data[link_end] >= 0x7f))
link_end++;

link_end = autolink_delim(data, link_end, max_rewind, size);
Expand Down Expand Up @@ -280,7 +280,7 @@ sd_autolink__url(
return 0;

link_end += domain_len;
while (link_end < size && !isspace(data[link_end]))
while (link_end < size && (!isspace(data[link_end]) || data[link_end] >= 0x7f))
link_end++;

link_end = autolink_delim(data, link_end, max_rewind, size);
Expand Down
14 changes: 14 additions & 0 deletions test/markdown_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,20 @@ def test_whitespace_after_urls
assert_equal exp, rd
end

# See https://github.com/vmg/redcarpet/pull/358 for more details
def test_auto_linked_www_utf8_issue
rd = render_with({ autolink: true }, "www.example.com/码")
exp = %{<p><a href="http://www.example.com/%E7%A0%81">www.example.com/码</a></p>\n}
assert_equal exp, rd
end

# See https://github.com/vmg/redcarpet/pull/358 for more details
def test_auto_linked_url_utf8_issue
rd = render_with({ autolink: true }, "http://example.com/码")
exp = %{<p><a href="http://example.com/%E7%A0%81">http://example.com/码</a></p>\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
Expand Down