From 3930e3a7aeb3e36bcae7f0b49c09d9cdfe9a72a7 Mon Sep 17 00:00:00 2001 From: Jordan Milne Date: Sun, 8 Mar 2015 13:50:30 -0700 Subject: [PATCH] Fix handling of raw control characters in autolinked URLs Control characters == 2 in the escape table, don't skip by those! --- html/houdini_href_e.c | 4 +++- test_snudown.py | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/html/houdini_href_e.c b/html/houdini_href_e.c index dcec3eb..581df1f 100644 --- a/html/houdini_href_e.c +++ b/html/houdini_href_e.c @@ -62,7 +62,9 @@ houdini_escape_href(struct buf *ob, const uint8_t *src, size_t size) while (i < size) { org = i; - while (i < size && HREF_SAFE[src[i]] != 0) + /* Skip by characters that don't need special + * processing */ + while (i < size && HREF_SAFE[src[i]] == 1) i++; if (i > org) diff --git a/test_snudown.py b/test_snudown.py index fd85bcc..c64155e 100644 --- a/test_snudown.py +++ b/test_snudown.py @@ -11,6 +11,9 @@ 'http://www.reddit.com': '

http://www.reddit.com

\n', + 'http://www.reddit.com/a\x00b': + '

http://www.reddit.com/ab

\n', + '[foo](http://en.wikipedia.org/wiki/Link_(film\))': '

foo

\n',