Support supplementary Unicode and emoji sequences#357
Conversation
|
@TomWright I feel like this might be enough for everyone, without a need for a plugin. I'm curious what you think about my implementation compared to yours in TomWright/dasel#549 |
|
I've tested these changes in dasel locally using the tests in my PR TomWright/dasel#549 and it's all green. My only comment would mirror the AI review on the bounds checks to make sure we don't get panics, but since I haven't seen them happen before I'm guessing there's some safety checks somewhere up the call stack? |
👍
🎉
I will assume you are talking about this isPrintable is used at two places:
About the scanner, I think we are safe because libyaml always make sure to fetch a few more character. But scanning a YAML ending with an invalid UTF-8 character could panic. Then about emitter, I'm unsure it's possible, but to write something invalid. I will give a try. That said, if you take a look at isPrintable, the line above are also requesting i+1 and i+2. So if the potential bug already exists. I think this should be addressed in another issue once we will validate it can occur. I would like to keep the PR simple, but I can give a try and see how much work it could be. |
|
For records, I have checked:
YAML somehow prevents this. And the scanner is built to avoid issues. I also tried with a YAML
The fix for the emitter is easy. I plan to add tests for both. But as I said it would be in another PR. For now, I created #358 to keep a track of the issue |
|
OK great. All sounds good to me, I'm happy for you to go ahead. Appreciate the speedy response! |
|
Just address the copilot comment regarding the name of the test @ccoVeille |
Treat valid 4-byte UTF-8 scalars as printable so supplementary Unicode characters and emoji sequences parse correctly.
| want: | | ||
| - ! "\U0001F600" | ||
| - ! "\U0001F44D\U0001F3FD" | ||
| - ! "\U0001F1FA\U0001F1F8" | ||
| - ! "\U0001F3F3\uFE0F\u200D\U0001F308" | ||
| - ! "\U0001F469\U0001F3FC\u200D\u2764\uFE0F\u200D\U0001F48B\u200D\U0001F468\U0001F3FE" |
| want: | | ||
| - ! "\U00010000" | ||
| - ! "A\U0001F600\U00010001Z" |
Treat valid 4-byte UTF-8 scalars as printable so supplementary Unicode
characters and emoji sequences parse correctly.
Fixes #354
Supersedes #356