Skip to content

Fix: Move Magic checks from Escape to Unescape Unicode Characters#2195

Merged
GCHQDeveloper581 merged 3 commits intogchq:masterfrom
fjh1997:master
Feb 20, 2026
Merged

Fix: Move Magic checks from Escape to Unescape Unicode Characters#2195
GCHQDeveloper581 merged 3 commits intogchq:masterfrom
fjh1997:master

Conversation

@fjh1997
Copy link
Copy Markdown
Contributor

@fjh1997 fjh1997 commented Feb 15, 2026

Description

This PR fixes an issue where the Magic module would incorrectly identify Unicode-escaped strings (e.g., \u5927) as needing the Escape Unicode Characters operation instead of Unescape Unicode Characters.

The Problem

  • EscapeUnicodeCharacters.mjs had checks defined that matched \uXXXX patterns. This caused Magic to prioritize "Escaping" already escaped strings.
  • UnescapeUnicodeCharacters.mjs had no checks defined, so Magic ignored it.

The Fix

  • Removed checks from EscapeUnicodeCharacters.mjs.
  • Added the appropriate regex checks to UnescapeUnicodeCharacters.mjs to detect \u, %u, and U+ prefixes.

Testing

  • Input: \u5927\u8D5B\u5B89\u5FB7\u68EE
  • Before: Magic suggests "Escape Unicode Characters".
  • After: Magic correctly suggests "Unescape Unicode Characters" and decodes to "大赛安德森".

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Feb 15, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Contributor

@GCHQDeveloper581 GCHQDeveloper581 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you for your contribution.

@GCHQDeveloper581 GCHQDeveloper581 merged commit 976c8b2 into gchq:master Feb 20, 2026
2 checks passed
@GCHQDeveloper581
Copy link
Copy Markdown
Contributor

But I do have one question. Who is Major Anderson?

@fjh1997
Copy link
Copy Markdown
Contributor Author

fjh1997 commented Feb 21, 2026

But I do have one question. Who is Major Anderson?

Haha, good catch! Major Anderson is actually a 'ghost in the keyboard.' In Chinese pinyin input methods, when you haphazardly mash the keys 'dsads', the algorithm auto-completes it to 'da-sai-an-de-sen', which translates to 大-赛-安-德-森.

mkilijanek pushed a commit to mkilijanek/CyberChef that referenced this pull request Feb 23, 2026
Incorporates 37 upstream commits from gchq/CyberChef master including:
- Fix: Move Magic checks from Escape to Unescape Unicode Characters (gchq#2195)
- Paste spreadsheets as text (gchq#2200)
- Fix Roboto Mono font (gchq#2199)
- Fix return of buffer for PNG QR image generation (gchq#2125)
- Update JIMP (gchq#2171)
- Bump v10.22.1 (gchq#2193)
- Bump v10.22.0 (gchq#2189)
- Fixed Percent delimiter for hex encoding (gchq#2137)
- Added ability to paste Images from Clipboard (gchq#1876)
- Quoted Printable improvements (gchq#2186)
- Fix freeze when output text decoding fails (gchq#1573)
- Fix import operations with special chars (gchq#1040)
- Add Bech32 encode/decode operations
- Various bug fixes and improvements

Conflict resolution:
- Workflow files: kept Node 24 + actions@v4 (local upgrade)
- package.json: kept jsonwebtoken 9.0.0, fixJimpModule postinstall, added upstream 'tag' script
- package-lock.json: kept local version (consistent with jimp 1.6.0 install)
- sitemap.mjs: kept modern 'with' import assertion syntax
- Code.mjs: kept escaped curly brace regex for Node 24 compatibility
- newMinorVersion.mjs: added upstream ignoredAuthors constant

https://claude.ai/code/session_011xozAMdxys1JF7nLRQsMtg
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.

3 participants