Commit 1bc7f3a84e75620bcce633159295c713be202554

Martin Mitas 2017-07-14T02:22:15

render_url_escaped: Fix escaping of ampersand. This affected generating href attribute if links or src attribute of images.

diff --git a/md2html/render_html.c b/md2html/render_html.c
index 410bd7b..0b858ac 100644
--- a/md2html/render_html.c
+++ b/md2html/render_html.c
@@ -110,7 +110,7 @@ render_url_escaped(MD_RENDER_HTML* r, const MD_CHAR* data, MD_SIZE size)
     MD_OFFSET off = 0;
 
     #define URL_NEED_ESCAPE(ch)                                             \
-            (!ISALNUM(ch)  &&  strchr("-_.+!*'(),%#@?=;:/,+&$", ch) == NULL)
+            (!ISALNUM(ch)  &&  strchr("-_.+!*'(),%#@?=;:/,+$", ch) == NULL)
 
     while(1) {
         while(off < size  &&  !URL_NEED_ESCAPE(data[off]))
diff --git a/test/permissive-www-autolinks.txt b/test/permissive-www-autolinks.txt
index ec076c3..245d260 100644
--- a/test/permissive-www-autolinks.txt
+++ b/test/permissive-www-autolinks.txt
@@ -79,7 +79,7 @@ www.google.com/search?q=commonmark&hl=en
 
 www.google.com/search?q=commonmark&hl;
 .
-<p><a href="http://www.google.com/search?q=commonmark&hl=en">www.google.com/search?q=commonmark&amp;hl=en</a></p>
+<p><a href="http://www.google.com/search?q=commonmark&amp;hl=en">www.google.com/search?q=commonmark&amp;hl=en</a></p>
 <p><a href="http://www.google.com/search?q=commonmark">www.google.com/search?q=commonmark</a>&amp;hl;</p>
 ````````````````````````````````