Repository navigation
Commit 7042d99
Fix reference link title incorrectly kept when followed by garbage
cmark_parse_reference_inline() speculatively parses a link title after
a reference definition's URL. If what follows the title is not the end
of the line (i.e. there is trailing garbage), the function rewinds and
retries treating the URL's line as ending right after the URL, so that
the "title" text is left as ordinary paragraph content instead of
being consumed as part of the reference definition.
However, on this rewind path the previously scanned `title` chunk was
never reset, so the reference was still registered with that title
even though it was determined to be invalid. This let garbage-suffixed
"titles" leak into the parsed link, e.g.:
[bla]: /bla
"The title" garbage
[bla]
incorrectly produced `<a href="/bla" title="The title">`, even though
the CommonMark reference dingus (and any spec-conformant parser)
produces no title here, since `"The title" garbage` is not a valid
title specification.
Fix: reset `title` to an empty chunk on the rewind path, matching the
behavior of the "no title matched" branch just below it.
Added a regression test (Issue #468) to test/regression.txt covering
this exact case.
Fixes #4681 parent 9562204 commit 7042d99
2 files changed
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1495 | 1495 | | |
1496 | 1496 | | |
1497 | 1497 | | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
1498 | 1502 | | |
1499 | 1503 | | |
1500 | 1504 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| |||
0 commit comments