You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix backslash-escaped quotes breaking link titles with smarty-pants - #779
The rest of the title then lands in the tag as stray attributes ("x\" onclick=\"y" gives title="x" onclick="y"). With safe_mode on as well, the quote's hash leaks into the output instead: title="Saymd5-19d5...hi...".
smarty-pants adds " to the escape table, so _encode_backslash_escapes has already replaced \" with that hash by the time the link is built. _xml_escape_attr never sees a quote to escape, and unhashing at the end puts back a raw " inside the attribute. The fix turns the hash back into a quote before the title is escaped, so it comes out as ", the same as without the extra.
Test: new smarty_pants_escaped_title_quotes tm-case (inline link and image). It fails before the fix and passes after. python test.py has the same 14 failures as on master, and only the new case differs between the two runs.
The 4 red jobs are the timing-based ReDoS check (redos/issue493 took 4.1s on the macOS and Windows runners). The run on the first commit passed every job, and the only change since is the CHANGES.md line, so it looks like runner slowness. Could someone re-run them? I don't have permission to.
The build (3.11, macos-latest) failure is a timing fluke: markdown2/redos/issue493 ran in 4.130s against a 4-second timeout on that runner. The test is a ReDoS benchmark for bold/italic nesting patterns; our change only touches link title processing when smarty-pants is active. It passes on ubuntu-latest, windows-latest, and all other Python versions on macOS. Running the suite locally completes issue493 in 1.2s. The macOS 3.11 GitHub runner was just slow on this run.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With the
smarty-pantsextra, a backslash-escaped double quote in an inline link or image title closes thetitleattribute early:The rest of the title then lands in the tag as stray attributes (
"x\" onclick=\"y"givestitle="x" onclick="y"). Withsafe_modeon as well, the quote's hash leaks into the output instead:title="Saymd5-19d5...hi...".smarty-pants adds
"to the escape table, so_encode_backslash_escapeshas already replaced\"with that hash by the time the link is built._xml_escape_attrnever sees a quote to escape, and unhashing at the end puts back a raw"inside the attribute. The fix turns the hash back into a quote before the title is escaped, so it comes out as", the same as without the extra.Test: new
smarty_pants_escaped_title_quotestm-case (inline link and image). It fails before the fix and passes after.python test.pyhas the same 14 failures as on master, and only the new case differs between the two runs.