Merge pull request #146 from stevewolter/master
Fix issue #125 (formatting in TOCs) and out-of-bounds memory access in tab expansion
This commit is contained in:
commit
977e26e2c9
5 changed files with 28 additions and 3 deletions
|
@ -2707,10 +2707,10 @@ static void expand_tabs(hoedown_buffer *ob, const uint8_t *line, size_t size)
|
|||
size_t org = i;
|
||||
|
||||
while (i < size && line[i] != '\t') {
|
||||
i++;
|
||||
/* ignore UTF-8 continuation bytes */
|
||||
if ((line[i] & 0xc0) != 0x80)
|
||||
tab++;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i > org)
|
||||
|
|
|
@ -586,7 +586,7 @@ toc_header(hoedown_buffer *ob, const hoedown_buffer *content, int level, const h
|
|||
}
|
||||
|
||||
hoedown_buffer_printf(ob, "<a href=\"#toc_%d\">", state->toc_data.header_count++);
|
||||
if (content) escape_html(ob, content->data, content->size);
|
||||
if (content) hoedown_buffer_put(ob, content->data, content->size);
|
||||
HOEDOWN_BUFPUTSL(ob, "</a>\n");
|
||||
}
|
||||
}
|
||||
|
@ -654,7 +654,7 @@ hoedown_html_toc_renderer_new(int nesting_level)
|
|||
NULL,
|
||||
|
||||
NULL,
|
||||
NULL,
|
||||
rndr_normal_text,
|
||||
|
||||
NULL,
|
||||
toc_finalize
|
||||
|
|
15
test/Tests/Formatting in Table of Contents.html
Normal file
15
test/Tests/Formatting in Table of Contents.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
<ul>
|
||||
<li>
|
||||
<a href="#toc_0">Header with special & characters</a>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="#toc_1">With <code>Code</code></a>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="#toc_2">With <em>Emphasis</em></a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
5
test/Tests/Formatting in Table of Contents.text
Normal file
5
test/Tests/Formatting in Table of Contents.text
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Header with special & characters
|
||||
|
||||
## With `Code`
|
||||
|
||||
### With *Emphasis*
|
|
@ -92,6 +92,11 @@
|
|||
"input": "Tests/Escape character.text",
|
||||
"output": "Tests/Escape character.html"
|
||||
},
|
||||
{
|
||||
"input": "Tests/Formatting in Table of Contents.text",
|
||||
"output": "Tests/Formatting in Table of Contents.html",
|
||||
"flags": ["--html-toc", "-t", "3"]
|
||||
},
|
||||
{
|
||||
"input": "Tests/Math.text",
|
||||
"output": "Tests/Math.html",
|
||||
|
|
Loading…
Reference in a new issue