gettalong / kramdown

kramdown is a fast, pure Ruby Markdown superset converter, using a strict syntax definition and supporting several common extensions.
http://kramdown.gettalong.org
Other
1.72k stars 275 forks source link

backlashes in href of links/images are not unescaped #732

Closed KirilSoshnin closed 3 years ago

KirilSoshnin commented 3 years ago

Some characters, like _, are escaped in markdown as they represent markdown syntax (italics in the case of the underscore). Strings are escaped too, for example the backlash:

puts Kramdown::Document.new("http//test.com/test\\_this/and-that/now\r\n\r\n").to_html

<p>http//test.com/test_this/and-that/now</p>

However, in the href of links and images, the backlashes stay unescaped. For example:

puts Kramdown::Document.new("[TESTI\\_NG](http://test.com/test\\_this/and-that/now)\r\n\r\n").to_html

<p><a href="http://test.com/test\_this/and-that/now">TESTI_NG</a></p>

(the alt text is unescaped correctly)

Expected:

<p><a href="http://test.com/test_this/and-that/now">TESTI_NG</a></p>

Using Kramdown 2.3.1

Let me know if there's anything else I should provide.

gettalong commented 3 years ago

So am I right that you are saying: You specify the URL http://test.com/test\_this/and-that/now but you actually want the URL http://test.com/test_this/and-that/now?

If so, why don't you just use the correct URL without the backslash? The URL is not part of the paragraph text so the general escaping doesn't apply to it.