Repository navigation
Escape ampersands in image alt text and link titles - #780
Open
SwastikTripathi wants to merge 2 commits into
Open
SwastikTripathi wants to merge 2 commits into
SwastikTripathi wants to merge 2 commits into
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
_xml_escape_attrcomputes the&escape and then throws it away:The second assignment starts again from
attr, so a bare&is never escaped. Its two callers show it:Without
safe_mode, titles only come out right (AT&T) because the general ampersand pass escapes them later. Alt text is hashed before that pass, so it keeps the raw&in every mode, and insafe_modetitles are hashed too.The fix chains the replacements onto the ampersand-escaped string.
_AMPERSAND_REalready skips existing entities, so©stays as it is.Tests: new
attr_ampersand_escapeandattr_ampersand_escape_safe_modetm-cases (alt text, an image title and a link title with&and©). Both fail before the fix and pass after.python test.pyotherwise has the same 14 failures as on master.