Escape now protects tags containing non-ASCII characters - #1165
Open
Rohilalala wants to merge 1 commit into
Open
Escape now protects tags containing non-ASCII characters#1165Rohilalala wants to merge 1 commit into
Rohilalala wants to merge 1 commit into
Conversation
The escape and unescape patterns only recognised a tag whose content was
ASCII letters, digits or a few punctuation marks, while escapedTagPattern
in strings.go, which decides what the print functions unescape, accepts
anything but brackets. Text the print functions treated as an escaped tag
was therefore left untouched by Escape, and printing it dropped a
character:
Escape("[中[]") rendered as "[中]"
Escape("[Tom & Bob[]") rendered as "[Tom & Bob]"
Both patterns now use the same tag content as escapedTagPattern. Text that
already round-tripped is unaffected: Escape returns a longer string for a
tag whose content falls outside the old set, but it renders as it did
before.
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.
escapePatternandunescapePatterninutil.goaccept a tag whose content is ASCII letters, digits or a few punctuation marks.escapedTagPatterninstrings.go, which decides what the print functions treat as an escaped tag, accepts anything but brackets.So text that the print functions unescape can be left untouched by
Escape, and printing it then drops a character:Both patterns now use the same tag content as
escapedTagPattern.Text that already round-tripped is unaffected.
Escapereturns a longer string for a tag whose content falls outside the old set —[中]becomes[中[]where it was left alone — but it renders as it did before. Checked over a corpus of 34 tag shapes: 10 escape differently, all of them previously broken or newly protected, and every one renders identically to before.Not fixed, and unchanged from before:
Escape("[[:::x]")renders as[.