{"record":{"id":"a96c77fa411172e0","repo":"mozilla/pdf.js","slug":"illegal-character-ch","errorCode":null,"errorMessage":"Illegal character: ${ch}","messagePattern":"Illegal character: (.+?)","errorType":"exception","errorClass":"FormatError","httpStatus":null,"severity":"error","filePath":"src/core/parser.js","lineNumber":1354,"sourceCode":"        ch = this.nextChar();\n        if (ch === 0x3e) {\n          this.nextChar();\n          return Cmd.get(\">>\");\n        }\n        return Cmd.get(\">\");\n      case 0x7b: // '{'\n        this.nextChar();\n        return Cmd.get(\"{\");\n      case 0x7d: // '}'\n        this.nextChar();\n        return Cmd.get(\"}\");\n      case 0x29: // ')'\n        // Consume the current character in order to avoid permanently hanging\n        // the worker thread if `Lexer.getObj` is called from within a loop\n        // containing try-catch statements, since we would otherwise attempt\n        // to parse the *same* character over and over (fixes issue8061.pdf).\n        this.nextChar();\n        throw new FormatError(`Illegal character: ${ch}`);\n    }\n\n    // Start reading a command.\n    let str = String.fromCharCode(ch);\n    // A valid command cannot start with a non-visible ASCII character,\n    // and the next character may be (the start of) a valid command.\n    if (ch < 0x20 || ch > 0x7f) {\n      const nextCh = this.peekChar();\n      if (nextCh >= 0x20 && nextCh <= 0x7f) {\n        this.nextChar();\n        return Cmd.get(str);\n      }\n    }\n    const knownCommands = this.knownCommands;\n    let knownCommandFound = knownCommands?.[str] !== undefined;\n    while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {\n      // Stop if a known command is found and next character does not make\n      // the string a command.","sourceCodeStart":1336,"sourceCodeEnd":1372,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/parser.js#L1336-L1372","documentation":"Error \"Illegal character: ${ch}\" thrown in mozilla/pdf.js.","triggerScenarios":"Thrown at src/core/parser.js:1354 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the illegal character from the token being parsed; PDF lexical rules only allow regular characters outside delimiters and whitespace.","If the file is corrupted or truncated, obtain a clean copy of the PDF."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}