Skip to content

Unescape backslash-escaped quotes in link and image titles - #778

Open
SwastikTripathi wants to merge 2 commits into
trentm:masterfrom
SwastikTripathi:fix/link-title-escaped-quote
Open

SwastikTripathi wants to merge 2 commits into
trentm:masterfrom
SwastikTripathi:fix/link-title-escaped-quote

Conversation

@SwastikTripathi

Copy link
Copy Markdown
Contributor

A backslash-escaped quote in a link or image title comes out as a literal " in the tooltip:

markdown2.markdown('[a](http://x "Say \\"hi\\"")')
# before: <a href="http://x" title="Say &amp;quot;hi&amp;quot;">a</a>
# after:  <a href="http://x" title="Say &quot;hi&quot;">a</a>

The same happens in reference definitions ([ref]: http://x "Say \"hi\"") and image titles. " isn't in markdown2's backslash-escape table, so the title reaches _xml_escape_attr as Say \"hi\" and becomes Say \&quot;hi\&quot;. The escaped-ampersand handling then reads \&quot; as an escaped & and writes &amp;quot;.

The title now has \" and \' turned into plain quotes before it is escaped for the attribute, so they come out as &quot; and '. Titles without a backslash are untouched.

New case link_title_escaped_quotes covers an inline link, a single-quoted title with \', a reference link and an image. It fails before the change and passes after. The rest of the suite is unchanged (the same 14 known failures as on master).

Separate from this: with the smarty-pants extra, the same title comes out as title="Say "hi"", both before and after this change, because \" is swapped for a placeholder earlier on that path. I left that alone here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant