Fix parser bug where link label gets broken by ] in code span#643
Fix parser bug where link label gets broken by ] in code span#643Martin1887 merged 2 commits intopulldown-cmark:masterfrom
Conversation
|
It looks fine, merged. |
|
@Martin1887 would it be possible to release a 0.9.3 patch with this fix? This bug currently causes rustdoc to crash on some inputs, see for example rust-lang/rust#111117 and rust-lang/docs.rs#2131. We have a new lint, Looking at the roadmap for 0.10, it seems like the next major release still takes some time, so I'd appreciate it if you could make a point release. I've prepared an example diff for a potential patch release here, if that helps: v0.9.2...lukas-code:pulldown-cmark:0.9.3 Alternatively, we can work around this bug on the rustdoc side, which would probably just mean disabling the lint for the time being. |
|
I see it right. I could create a new branch from the What do you think, @raphlinus? |
|
The branch |
…rd, r=GuillaumeGomez update `pulldown-cmark` to `0.9.3` This PR updates `pulldown-cmark` to version `0.9.3`, which does two main things: * Pulls in pulldown-cmark/pulldown-cmark#643 to fix rust-lang#111117 * Allows parsing strikethrough with single tildes, e.g. `~foo~` -> ~foo~. This matches the [GFM spec](https://github.github.com/gfm/#strikethrough-extension-). Full changelog: pulldown-cmark/pulldown-cmark#646
…rd, r=GuillaumeGomez update `pulldown-cmark` to `0.9.3` This PR updates `pulldown-cmark` to version `0.9.3`, which does two main things: * Pulls in pulldown-cmark/pulldown-cmark#643 to fix rust-lang#111117 * Allows parsing strikethrough with single tildes, e.g. `~foo~` -> ~foo~. This matches the [GFM spec](https://github.github.com/gfm/#strikethrough-extension-). Full changelog: pulldown-cmark/pulldown-cmark#646
…llaumeGomez update `pulldown-cmark` to `0.9.3` This PR updates `pulldown-cmark` to version `0.9.3`, which does two main things: * Pulls in pulldown-cmark/pulldown-cmark#643 to fix rust-lang/rust#111117 * Allows parsing strikethrough with single tildes, e.g. `~foo~` -> ~foo~. This matches the [GFM spec](https://github.github.com/gfm/#strikethrough-extension-). Full changelog: pulldown-cmark/pulldown-cmark#646
When the parser encounters the
]at (C), it tries to parse a link label starting from the previous[at (A) until it encounters the first]at (B). This is fine, becauseHowever, due to
the code span
`]`takes precedence over the link closing.Since a link label must not contain a
]that is not immediately preceded by a\, the above must not be parsed as a link label.This patch fixes #642, a bug in the parser, where the range (A)...(C) was previously parsed as a shortcut link with the label (A)...(B) if the text between (A) and (B) [here:
before `] is a valid link reference. We do this by simply comparing the found end (B) and supposed end (C) to ensure that the link label closed by (C) actually ends at (C).As a bonus I've included a
#[derive(Debug)]that helped me debug this and removed an unneeded&. But I can drop the unrelated changes if you don't want them.