From 2038608bf8032db1da5fec58d3ce9a3d070c713b Mon Sep 17 00:00:00 2001 From: Martin Mitas Date: Mon, 11 Mar 2019 19:56:46 +0200 Subject: [PATCH] md_is_link_title: Stop on ')' lin ()-style title. Fixes #60. --- CHANGELOG.md | 3 ++- md4c/md4c.c | 3 +++ test/pathological_tests.py | 5 ++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 810cf4a2..23b521a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,8 @@ Fixes: * Fixed some quadratic behaviors: [#58](https://github.com/mity/md4c/issues/58), - [#59](https://github.com/mity/md4c/issues/59) + [#59](https://github.com/mity/md4c/issues/59), + [#60](https://github.com/mity/md4c/issues/60) * [#61](https://github.com/mity/md4c/issues/59): Flag `MD_FLAG_NOHTMLSPANS` erroneously affected also recognition of CommonMark autolinks. diff --git a/md4c/md4c.c b/md4c/md4c.c index d56f67da..6dafccb6 100644 --- a/md4c/md4c.c +++ b/md4c/md4c.c @@ -2058,6 +2058,9 @@ md_is_link_title(MD_CTX* ctx, const MD_LINE* lines, int n_lines, OFF beg, *p_end = off+1; *p_end_line_index = line_index; return TRUE; + } else if(closer_char == _T(')') && CH(off) == _T('(')) { + /* ()-style title cannot contain (unescaped '(')) */ + return FALSE; } off++; diff --git a/test/pathological_tests.py b/test/pathological_tests.py index 96e00417..2d7c7009 100755 --- a/test/pathological_tests.py +++ b/test/pathological_tests.py @@ -74,7 +74,10 @@ re.compile("(<>){50000}")), "many backticks and escapes": (("\\``" * 50000), - re.compile("(``){50000}")) + re.compile("(``){50000}")), + "many broken link titles": + (("[ (](" * 50000), + re.compile("(\[ \(\]\(){50000}")) } whitespace_re = re.compile('/s+/')