{"record":{"id":"92343406510c53a5","repo":"quarkusio/quarkus","slug":"only-latin-characters-are-supported","errorCode":null,"errorMessage":"Only Latin characters are supported: ","messagePattern":"Only Latin characters are supported: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/qute/core/src/main/java/io/quarkus/qute/HtmlEscaper.java","lineNumber":37,"sourceCode":"    private static byte[] createLatinReplacementData() {\n        byte[] data = new byte[256];\n        // by default we don't escape anything i.e. the escaped index is 0!\n        setLatinReplacementId(data, '\"', 1);\n        setLatinReplacementId(data, '\\'', 2);\n        setLatinReplacementId(data, '&', 3);\n        setLatinReplacementId(data, '<', 4);\n        setLatinReplacementId(data, '>', 5);\n        assert getLatinReplacementId(data, '\"') == 1;\n        assert getLatinReplacementId(data, '\\'') == 2;\n        assert getLatinReplacementId(data, '&') == 3;\n        assert getLatinReplacementId(data, '<') == 4;\n        assert getLatinReplacementId(data, '>') == 5;\n        return data;\n    }\n\n    private static void setLatinReplacementId(byte[] data, int c, int id) {\n        if (c > 255) {\n            throw new IllegalArgumentException(\"Only Latin characters are supported: \" + c);\n        }\n        if (id < 0 || id > 15) {\n            throw new IllegalArgumentException(\"Replacement ID must be in range [0, 15] but was: \" + id);\n        }\n        data[c] = (byte) id;\n    }\n\n    private static int getLatinReplacementId(byte[] data, int c) {\n        return data[c] & REPLACEMENT_ID_MASK;\n    }\n\n    private static String replacementOf(char c) {\n        if (c > 255) {\n            return null;\n        }\n        int replacementId = getLatinReplacementId(LATIN_REPLACEMENT_ID_TABLE, c & 0xFF);\n        // in the super class we still have to perform a null check vs String, which means\n        // we can have a branch misprediction there.","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/qute/core/src/main/java/io/quarkus/qute/HtmlEscaper.java#L19-L55","documentation":"HtmlEscaper's replacement table maps byte values 0-255 to escape-replacement ids. setLatinReplacementId() throws IllegalArgumentException when asked to register a character code greater than 255, because the table only covers Latin-1 characters. This guards the static table-building code from non-Latin characters.","triggerScenarios":"Internal configuration/build of the escape table with a character code > 255 — practically only reachable if createLatinReplacementData is modified or a caller registers a non-Latin (e.g. Unicode) character as a replacement target.","commonSituations":"Contributing a patch or customizing HtmlEscaper to add extra escape characters and using a code point beyond 255 (e.g. typographic quotes, em dash).","solutions":["Only register escape replacements for characters with code point <= 255 in the table.","Handle non-Latin characters with a separate escaping mechanism (e.g. a map checked before the byte table).","If this fires unexpectedly, audit any local modifications to createLatinReplacementData for bad character constants."],"exampleFix":"// before\nsetLatinReplacementId(data, '\\u2014', 12); // em dash > 255 -> throws\n// after\nif ('\\u2014' <= 255) {\n    setLatinReplacementId(data, '\\u2014', 12);\n} // handle em dash elsewhere, e.g. in a separate unicode escape map","handlingStrategy":"validation","validationCode":"if (codePoint > 255) {\n    // route to a separate unicode escaping path, not the Latin-1 byte table\n}","typeGuard":"boolean isLatin1(int c) { return c >= 0 && c <= 255; }","tryCatchPattern":"try {\n    setLatinReplacementId(data, c, id);\n} catch (IllegalArgumentException ex) {\n    LOGGER.error(\"non-Latin escape char in table: {}\", ex.getMessage());\n    throw ex;\n}","preventionTips":["Only register characters with code point <= 255 in HtmlEscaper's table","Escape non-Latin characters via a separate mechanism","Add an assertion/test iterating table entries for code point bounds"],"tags":["qute","html-escaping","illegal-argument","latin1"],"backgroundTag":"argument-out-of-range","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}