diff options
author | Jordan Milne <jordan.milne@saynotolinux.com> | 2014-09-12 04:42:30 -0300 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2014-09-17 16:21:24 +0200 |
commit | 3aa56049d4b52b55a2313e51698090ee81e10036 (patch) | |
tree | 79603c00f95a6f70eba44bb536c8970c8fe7ac97 | |
parent | 118e3d3c39242225baa876319cdbfbb1adadc77b (diff) |
Better handle trailing backslashes in ATX-style headers
Previously something like '# `\' would hang the parser while it
waited for an extra character that wasn't there.
-rw-r--r-- | src/blocks.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/blocks.c b/src/blocks.c index 2ac7032..5b38116 100644 --- a/src/blocks.c +++ b/src/blocks.c @@ -420,17 +420,17 @@ extern node_block *stmd_parse_document(const unsigned char *buffer, size_t len) static void chop_trailing_hashtags(chunk *ch) { - int n; + int n, orig_n; chunk_rtrim(ch); - n = ch->len - 1; + orig_n = n = ch->len - 1; // if string ends in #s, remove these: while (n >= 0 && peek_at(ch, n) == '#') n--; // the last # was escaped, so we include it. - if (n >= 0 && peek_at(ch, n) == '\\') + if (n != orig_n && n >= 0 && peek_at(ch, n) == '\\') n++; ch->len = n + 1; |