Hi,

Thanks for this patch, which also fixes the issue with one or more
spaces between backticks I had mentioned on this list before, see
below.
My proposal was to change markdown.c, but I can confirm that the fix
in markdown_html.c also works.

Regards,
Johan


---------------------------


Hi,

An odd, but valid Markdown document:

echo '` `' > oops.md

- John Gruber's Markdown:

        markdown < oops.md
        <p><code></code></p>

- MMD:

        multimarkdown < oops.md
        <p><code></code></p> (no trailing newline)

- CommonMark:

        cmark < oops.md
        <p><code></code></p>

Fossil, anyhow, segfaults:

printf "%s\n\n" "GET /doc/ckout/oops.md HTTP/1.0" | fossil http
Segmentation fault (core dumped)

The patch passes a zero-initialized text Blob instead of a NULL text
object to html_code_span() in case the trimmed string between the
backticks is empty.

Best Regards,
Johan



Index: src/markdown.c
==================================================================
--- src/markdown.c
+++ src/markdown.c
@@ -745,17 +745,15 @@
   }
   f_end = end-nb;
   while( f_end>nb && (data[f_end-1]==' ' || data[f_end-1]=='\t') ){ f_end--; }

   /* real code span */
+  struct Blob work = BLOB_INITIALIZER;
   if( f_begin<f_end ){
-    struct Blob work = BLOB_INITIALIZER;
     blob_init(&work, data+f_begin, f_end-f_begin);
-    if( !rndr->make.codespan(ob, &work, rndr->make.opaque) ) end = 0;
-  }else{
-    if( !rndr->make.codespan(ob, 0, rndr->make.opaque) ) end = 0;
   }
+  if( !rndr->make.codespan(ob, &work, rndr->make.opaque) ) end = 0;
   return end;
 }


 /* char_escape -- '\\' backslash escape */

On Fri, Jul 28, 2017 at 10:15 PM, Ross Berteig <[email protected]> wrote:
>
> On 7/28/2017 11:41 AM, Richard Hipp wrote:
>>
>> On 7/28/17, Florian Balmer <[email protected]> wrote:
>>>
>>> ----------
>>> * The first list: ...
>>> * The second list: `|` `<` ...
>>> ----------
>>>
>>> causes a crash
>>
>> Thanks for the bug report.  Now fixed on trunk.
>
>
> I *really* wish that Automattic (the owners of Wordpress.com) would be as
> responsive as you are!
>
> I've reported a number of "quirks" and outright bugs with their
> implementation of Markdown for Wordpress, and have yet to receive anything
> more than "wait, we support Markdown?" or  "Why would you use that when you
> can just use our wonderful hodgepodge of HTML and quirky custom extensions?"
> as a response.
>
> I'd add these examples to my blog post that demonstrates their bugs, but I
> fear what it might do...  ;-)
>
> --
> Ross Berteig                               [email protected]
> Cheshire Engineering Corp.           http://www.CheshireEng.com/
> +1 626 303 1602
>
>
> _______________________________________________
> fossil-users mailing list
> [email protected]
> http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users
_______________________________________________
fossil-users mailing list
[email protected]
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to