{"record":{"id":"8ec55ddc48c7a1bf","repo":"gchq/CyberChef","slug":"val-is-not-a-base92-character","errorCode":null,"errorMessage":"${val} is not a base92 character","messagePattern":"(.+?) is not a base92 character","errorType":"validation","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/lib/Base92.mjs","lineNumber":42,"sourceCode":"        return \"#\".charCodeAt(0) + val - 1;\n    else\n        return \"a\".charCodeAt(0) + val - 62;\n}\n\n/**\n * Base92 alphabet ord\n *\n * @param {string} val\n * @returns {number}\n */\nexport function base92Ord(val) {\n    if (val === \"!\")\n        return 0;\n    else if (\"#\" <= val && val <= \"_\")\n        return val.charCodeAt(0) - \"#\".charCodeAt(0) + 1;\n    else if (\"a\" <= val && val <= \"}\")\n        return val.charCodeAt(0) - \"a\".charCodeAt(0) + 62;\n    throw new OperationError(`${val} is not a base92 character`);\n}\n\n","sourceCodeStart":24,"sourceCodeEnd":45,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/lib/Base92.mjs#L24-L45","documentation":"Thrown by base92Ord(val) in src/core/lib/Base92.mjs:42 when the input character is not part of the Base92 alphabet recognised by this library ('!', '#'..'_', 'a'..'}'). The function walks three branches and only throws on exhaustion, so any character outside those three ranges — including space, double-quote, backtick, tilde, control chars, or any uppercase letter — is rejected.","triggerScenarios":"Direct call base92Ord(' '), base92Ord('A'), base92Ord('~'), base92Ord(''). Indirectly: decoding a string that contains whitespace, uppercase, or characters from a different Base92 variant (there are several incompatible Base92 definitions) using this library's decoder.","commonSituations":"Decoding Base92 produced by a different implementation with a different alphabet ordering; copy-paste that introduced spaces or newlines; mixed-case input where uppercase letters are not in this alphabet; treating arbitrary ASCII as Base92.","solutions":["Pre-filter the input to the accepted alphabet: s.replace(/[^!#-_a-}]/g, '').","Confirm the source used the same Base92 dialect as this library before decoding.","Trim whitespace and newlines from pasted input.","Wrap decoding in try/catch and report the offending character to the user."],"exampleFix":"// before - uppercase 'A' is not in this Base92 alphabet\nconst v = base92Ord('A');\n\n// after - strip characters outside the accepted ranges first\nconst cleaned = input.replace(/[^!#-_a-}]/g, '');\nconst v = base92Ord(cleaned[i]);","handlingStrategy":"validation","validationCode":"function cleanBase92(s) {\n  return s.replace(/[^!#-_a-}]/g, '');\n}\n// then decode(cleanBase92(input))","typeGuard":"function isBase92AlphabetChar(ch) {\n  return typeof ch === 'string' && ch.length === 1 && /^[!#\\-_a-}]$/.test(ch);\n}","tryCatchPattern":"try {\n  const val = base92Ord(ch);\n} catch (e) {\n  if (e instanceof OperationError && /not a base92 character/.test(e.message)) {\n    // skip or substitute the offending character\n  }\n}","preventionTips":["Confirm the source used the same Base92 alphabet dialect as this library.","Strip whitespace, uppercase, and control characters before decoding.","Wrap the decode loop to collect and report all bad characters at once."],"tags":["base92","decoding","alphabet","input-validation"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}