gchq/CyberChef · error · OperationError
Invalid ITA2 character : ${errltr}
Error message
Invalid ITA2 character : ${errltr} What it means
Thrown by the Lorenz SZ operation when, in ITA2 input mode, an input character does not map to a valid ITA2 code. The operation supports two input paths: when intype==='ITA2' or mode==='Receive' (Lorenz.mjs:515), each character is looked up against validITA2; if it is not found the character is rejected. Newlines and spaces are renamed to 'Carriage Return' and 'Space' in the message for clarity. This enforces the 5-bit ITA2 alphabet used by the real teleprinter.
Source
Thrown at src/core/operations/Lorenz.mjs:515
}
/**
* Convert input plaintext to ITA2
*/
convertToITA2(input, intype, mode) {
let result = "";
let figShifted = false;
for (const character of input) {
const letter = character.toUpperCase();
// Convert input text to ITA2 (including figure/letter shifts)
if (intype === "ITA2" || mode === "Receive") {
if (validITA2.indexOf(letter) === -1) {
let errltr = letter;
if (errltr==="\n") errltr = "Carriage Return";
if (errltr===" ") errltr = "Space";
throw new OperationError("Invalid ITA2 character : "+errltr);
}
result += letter;
} else {
if (validChars.indexOf(letter) === -1) throw new OperationError("Invalid Plaintext character : "+letter);
if (!figShifted && figShiftedChars.indexOf(letter) !== -1) {
// in letters mode and next char needs to be figure shifted
figShifted = true;
result += "55" + figShiftArr[letter];
} else if (figShifted) {
// in figures mode and next char needs to be letter shifted
if (letter==="\n") {
result += "34";
} else if (letter==="\r") {
result += "4";
} else if (figShiftedChars.indexOf(letter) === -1) {
figShifted = false;
result += "88" + letter;View on GitHub (pinned to 4290ea7539)
Solutions
- Provide only characters that exist in the ITA2 alphabet (the operation upper-cases input, so use the ITA2 letter/figure-shift characters).
- If your data is plaintext, set 'Input Type' to 'Plaintext' (and 'Mode' to 'Send') so it is encoded into ITA2 for you.
- For digits and punctuation, supply them as plaintext in Send mode so figure/letter shifts are inserted automatically.
- Strip or replace unsupported characters (e.g. tabs, Unicode) before feeding the ITA2 path.
Example fix
// before — digits/unicode fed directly to ITA2 path // intype='ITA2', input='HELLO 123 ✓' // after — send as Plaintext so the op encodes to ITA2 // intype='Plaintext', input='HELLO 123'
Defensive patterns
Strategy: validation
Validate before calling
// Mirror the operation's own alphabet: ITA2-valid characters.
// Build the set from the same source the op uses, or maintain an explicit allow-list.
const VALID_ITA2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890/+-%"#&\\'():,=!.?';\nfunction onlyITA2(str) {
return [...str.toUpperCase()].every(c => VALID_ITA2.includes(c) || c === '\n' || c === ' ');
}
if ((intype === 'ITA2' || mode === 'Receive') && !onlyITA2(input)) {
throw new Error('Input contains non-ITA2 characters');
} Type guard
function isITA2String(v: unknown): v is string {
if (typeof v !== 'string') return false;
const allowed = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890/+-%"#&\'():,=!.?';
return [...v.toUpperCase()].every(c => allowed.includes(c) || c === '\n' || c === ' ');
} Prevention
- When data is plaintext, use Input Type 'Plaintext' / Mode 'Send' so the op encodes ITA2 for you.
- Filter or transliterate non-ITA2 characters before the ITA2 path.
- Treat digits/punctuation as plaintext, not literal ITA2 input.
When it happens
Trigger: Setting 'Input Type' to 'ITA2' (or 'Mode' to 'Receive') and feeding input containing characters outside the ITA2 set — e.g. lowercase letters (only after toUpperCase most are valid, but punctuation not in ITA2 is not), digits as digits rather than their figure-shift codes, or extended Unicode. Triggered at Lorenz.mjs:515 inside the per-character loop.
Common situations: Pasting arbitrary UTF-8 text into an ITA2 field; expecting digits '0'-'9' to be accepted directly (ITA2 encodes them via figure shift, not as literal digits); feeding a Space or newline where the receiver is configured for strict ITA2; mixing Receive mode with plaintext content.
Related errors
- Invalid Plaintext character : ${letter}
- Χ1 custom lugs must be 41 long and can only include . or x
- Χ2 custom lugs must be 31 long and can only include . or x
- Χ3 custom lugs must be 29 long and can only include . or x
- Χ4 custom lugs must be 26 long and can only include . or x
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/7cebe837967e7175.
Report an issue: GitHub.