Don't escape certain non-ascii characters#486
Merged
slyon merged 1 commit intocanonical:mainfrom Jul 3, 2024
Merged
Conversation
f6c1882 to
28c0293
Compare
slyon
suggested changes
Jul 3, 2024
Contributor
slyon
left a comment
There was a problem hiding this comment.
Looks fine overall, but we might whitelist some control characters that we don't want to have un-escaped (like DELETE). Can you please clarify on this?
And maybe also add a small unit-test around it, so that we can see the actual characters being used?
g_strescape will transform utf-8 strings in a sequence of escaped octal numbers in form of a string. That happens because g_strescape will escape the range from 0x7f to 0xff. For example, "áéí" will become "\\303\\241\\303\\251\\303\\255". Pure ASCII strings are not affected by it. Add all the range 0x7f-0xff to the exception list.
28c0293 to
2fda0a0
Compare
Contributor
Author
|
I removed 0x7f from the list and rebased. I also added a unittest using the wifi password. |
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.
Description
g_strescape will mess up with utf-8 characters. It happens because all the range from 0x7f to 0xff are escaped by default. The bytes in this range can be found in utf-8 code points so non-ascii strings will end being changed.
This PR adds all the range in the exception list.
For example, the file below:
will become this (output from
netplan get):With the new exceptions it will become:
Checklist
make checksuccessfully.make check-coverage).