From 5a98946b2bd3d5f7df8d33c654205a7301db25bd Mon Sep 17 00:00:00 2001 From: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> Date: Fri, 25 Apr 2025 18:05:11 +0900 Subject: [PATCH 1/3] Fix image tag with external source When `rdoc-image` contains an external source, such as `https://example.com/path/to/image.svg`, rendered `` tag is broken. This fixes the bug. For example, I found the problem on the IRB website, where a Markdown image is present as a source. Rendered HTML on the website : ```html //badge.fury.io/rb/irb.svg:Gem Version ``` Markdown source: ```markdown [![Gem Version](https://badge.fury.io/rb/irb.svg)](https://badge.fury.io/rb/irb) ``` Probably, this bug was introduced in the commit 894b2f1cd147a760449a52b621af7bf206452127 (v6.13.0). --- lib/rdoc/markup/to_html.rb | 6 +++++- test/rdoc/test_rdoc_markup_to_html.rb | 30 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/lib/rdoc/markup/to_html.rb b/lib/rdoc/markup/to_html.rb index aabbb2038a..9c7b3f0de3 100644 --- a/lib/rdoc/markup/to_html.rb +++ b/lib/rdoc/markup/to_html.rb @@ -98,7 +98,11 @@ def handle_RDOCLINK(url) # :nodoc: gen_url CGI.escapeHTML(url), CGI.escapeHTML(text) when /^rdoc-image:/ - url, alt = $'.split(":", 2) # Split the string after "rdoc-image:" into url and alt + # Split the string after "rdoc-image:" into url and alt + url_alt = $' + split_pos = url_alt.index(%r{:[^/]}) + url = split_pos ? url_alt[0, split_pos] : url_alt + alt = split_pos ? url_alt[split_pos + 1, url_alt.size] : nil if alt && !alt.empty? %[#{CGI.escapeHTML(alt)}] else diff --git a/test/rdoc/test_rdoc_markup_to_html.rb b/test/rdoc/test_rdoc_markup_to_html.rb index 26b9999ed0..e586e03cb9 100644 --- a/test/rdoc/test_rdoc_markup_to_html.rb +++ b/test/rdoc/test_rdoc_markup_to_html.rb @@ -749,6 +749,36 @@ def test_convert_TIDYLINK_image assert_not_include result, "