{"record":{"id":"df0bdb6070550166","repo":"jhy/jsoup","slug":"invalid-escape-sequence","errorCode":null,"errorMessage":"Invalid escape sequence: ","messagePattern":"Invalid escape sequence: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/org/jsoup/parser/TokenQueue.java","lineNumber":384,"sourceCode":"    }\n\n    private void consumeCssEscapeSequenceInto(StringBuilder out) {\n        if (isEmpty()) {\n            out.append(Replacement);\n            return;\n        }\n\n        char firstEscaped = consume();\n        if (!StringUtil.isHexDigit(firstEscaped)) {\n            out.append(firstEscaped);\n        } else {\n            reader.unconsume(); // put back the first hex digit\n            String hexString = reader.consumeMatching(StringUtil::isHexDigit, 6); // consume up to 6 hex digits\n            int codePoint;\n            try {\n                codePoint = Integer.parseInt(hexString, 16);\n            } catch (NumberFormatException e) {\n                throw new IllegalArgumentException(\"Invalid escape sequence: \" + hexString, e);\n            }\n            if (isValidCodePoint(codePoint)) {\n                out.appendCodePoint(codePoint);\n            } else {\n                out.append(Replacement);\n            }\n\n            if (!isEmpty()) {\n                char c = current();\n                if (c == '\\r') {\n                    // Since there's currently no input preprocessing, check for CRLF here.\n                    // https://www.w3.org/TR/css-syntax-3/#input-preprocessing\n                    advance();\n                    if (!isEmpty() && current() == '\\n') advance();\n                } else if (c == ' ' || c == '\\t' || isNewline(c)) {\n                    advance();\n                }\n            }","sourceCodeStart":366,"sourceCodeEnd":402,"githubUrl":"https://github.com/jhy/jsoup/blob/9851ac5d9c576c6888910b5a51a2362bbc978959/src/main/java/org/jsoup/parser/TokenQueue.java#L366-L402","documentation":"Selector-syntax error from TokenQueue's CSS escape handling (consumeCssEscapeSequenceInto): a backslash escape in an identifier did not resolve to a valid character — e.g. a malformed hex escape like \"\\xZZ\", an empty escape at end of input, or a hex value that cannot form a valid code point. The input at fault is the escaped identifier text in the user's CSS selector.","triggerScenarios":"Thrown at src/main/java/org/jsoup/parser/TokenQueue.java:384 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use well-formed CSS escapes: backslash + up to 6 hex digits, or backslash + a literal non-hex character.","Catch Selector.SelectorParseException and report the offending selector to the user instead of letting it propagate.","Prefer correctly escaped identifiers (e.g. \\31 for leading digits) over raw unsupported syntax."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9851ac5d9c576c6888910b5a51a2362bbc978959","analyzedAt":"2026-09-08T15:22:04.931Z","contentChangedAt":"2026-09-08T15:22:04.931Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}