fix: tighten span tag parsing #4061
Merged
+21
−17
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.
Fixes #4059
Fixes: #2890
This makes the splitting of the attributes part of a StyledString span's tag stricter.
Unfortunately, the way these tags are encoded is very ambiguous, so we make a best guess approach to cover all known cases.
Example:
<span href="https://test.com/1234#param=val" style="font-family: serif; font-size:12px;">Is encoded as:
span;href=https://test.com/1234#param=val;style=font-family: serif; font-size:12px;The keys have a specific set of valid characters, but the values can contain any character, including the separators
;and=.We're splitting on
;but with a lookahead for a valid key followed by=.This is not 100% fail-proof and won't decode accurately if a value contains a
;followed by a valid key format, but at least it won't crash (discussed in the comment below).Added test cases as well.