Skip to content

Fix unicode color diff.#93

Merged
josephburnett merged 1 commit intojosephburnett:masterfrom
roberthoenig:fix_unicode_color_diff
Mar 27, 2025
Merged

Fix unicode color diff.#93
josephburnett merged 1 commit intojosephburnett:masterfrom
roberthoenig:fix_unicode_color_diff

Conversation

@roberthoenig
Copy link
Copy Markdown
Contributor

The character-level color diff introduced in a907909 breaks for unicode characters. Fix this by processing strings as runes instead of bytes. Add a regression test.

The character-level color diff introduced in a907909
breaks for unicode characters. Fix this by processing
strings as runes instead of bytes. Add a regression test.
@josephburnett
Copy link
Copy Markdown
Owner

Nice catch @roberthoenig

@josephburnett josephburnett merged commit 8b6d68a into josephburnett:master Mar 27, 2025
1 check passed
@josephburnett
Copy link
Copy Markdown
Owner

Released as v2.2.2

@josephburnett
Copy link
Copy Markdown
Owner

josephburnett commented Apr 7, 2025

@roberthoenig I added color diffs to the fuzz testing which also would have caught this bug. And the fuzzing found another bug too with escaping some ASCII characters! To find this bug I dove into the details of Go's JSON serialization logic for strings. It was much more complex than I expected! Just FYI in case you're interested.

@roberthoenig
Copy link
Copy Markdown
Contributor Author

@josephburnett interesting, thanks for sharing and for fixing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants