summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Mendez <me@jmendeth.com>2014-12-01 17:32:53 +0100
committerXavier Mendez <me@jmendeth.com>2014-12-01 17:32:53 +0100
commit977e26e2c9dbd39622935d16ef82cbe82d4bc977 (patch)
tree10e0e53e70b78e4747d60f0509aeefded0fa032d
parent3afc3ec505dd7dd902086f8c158290962e705663 (diff)
parent4825466fefe0cfd6270baf8582b6674ebc7f21dd (diff)
downloadrust-hoedown-977e26e2c9dbd39622935d16ef82cbe82d4bc977.tar.gz
Merge pull request #146 from stevewolter/master
Fix issue #125 (formatting in TOCs) and out-of-bounds memory access in tab expansion
-rw-r--r--src/document.c2
-rw-r--r--src/html.c4
-rw-r--r--test/Tests/Formatting in Table of Contents.html15
-rw-r--r--test/Tests/Formatting in Table of Contents.text5
-rw-r--r--test/config.json5
5 files changed, 28 insertions, 3 deletions
diff --git a/src/document.c b/src/document.c
index 3ce4416..47f6cf2 100644
--- a/src/document.c
+++ b/src/document.c
@@ -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)
diff --git a/src/html.c b/src/html.c
index ddebff7..9eea3a1 100644
--- a/src/html.c
+++ b/src/html.c
@@ -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
diff --git a/test/Tests/Formatting in Table of Contents.html b/test/Tests/Formatting in Table of Contents.html
new file mode 100644
index 0000000..8e7be95
--- /dev/null
+++ b/test/Tests/Formatting in Table of Contents.html
@@ -0,0 +1,15 @@
+<ul>
+<li>
+<a href="#toc_0">Header with special &amp; 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>
diff --git a/test/Tests/Formatting in Table of Contents.text b/test/Tests/Formatting in Table of Contents.text
new file mode 100644
index 0000000..b95fbaa
--- /dev/null
+++ b/test/Tests/Formatting in Table of Contents.text
@@ -0,0 +1,5 @@
+# Header with special & characters
+
+## With `Code`
+
+### With *Emphasis*
diff --git a/test/config.json b/test/config.json
index 63cb1d7..b6ecb55 100644
--- a/test/config.json
+++ b/test/config.json
@@ -93,6 +93,11 @@
"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",
"flags": ["--math"]