md_is_link_title: Stop on ')' lin ()-style title. Fixes #60.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 810cf4a..23b521a 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 188cd80..50976d2 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 96e0041..2d7c700 100755
--- a/test/pathological_tests.py
+++ b/test/pathological_tests.py
@@ -74,7 +74,10 @@ pathological = {
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+/')