Default user text to UTF-8#2646
Open
C85297 wants to merge 1 commit into
Open
Conversation
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
When users enter text into CyberChef, it should probably be assumed they are typing UTF-8 text.
Instead, if the user has the default "Raw Bytes" selected, CyberChef interprets the text ambiguously - if the first operation takes ArrayBuffer input and the input contains only code units up to
0xFF, each code unit is used as a single byte. For example,ábecomese1, so directMD5hashes bytee1. But, if the input contains at least one code unit above0xFF, the entire input is encoded as UTF-8. For example,اábecomesd8 a7 c3 a1, so the sameácharacter is represented as UTF-8 bytesc3 a1only because another character in the same input forced UTF-8 conversion. This makes byte-oriented results depend not only on a character itself, but also on whether any other character in the same input falls outside the single-byte range. The sameácharacter is represented differently ináversusاáorわá.This PR updates CyberChef to default user input to UTF-8. File uploads remain raw bytes.
To retain behaviour in existing CyberChef links, I kept links without a specified encoding following the old behaviour. New links for user entered text will specify UTF-8 encoding. I wasn't 100% sure which way to go on this so would appreciate any thoughts.
Existing Issue
Closes #322
Closes #1127
Screenshots
No
AI disclosure
gpt-5.5
Test Coverage
Yes