{"record":{"id":"2276c93b9a72e10a","repo":"flowable/flowable-engine","slug":"invalid-escape-sequence","errorCode":null,"errorMessage":"invalid escape sequence \\\\","messagePattern":"invalid escape sequence \\\\\\\\","errorType":"exception","errorClass":"ScanException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/de/odysseus/el/tree/impl/Scanner.java","lineNumber":317,"sourceCode":"\t/**\n\t * string token\n\t */\n\tprotected Token nextString() throws ScanException {\n\t\tbuilder.setLength(0);\n\t\tchar quote = input.charAt(position);\n\t\tint i = position+1;\n\t\tint l = input.length();\n\t\twhile (i < l) {\n\t\t\tchar c = input.charAt(i++);\n\t\t\tif (c == '\\\\') {\n\t\t\t\tif (i == l) {\n\t\t\t\t\tthrow new ScanException(position, \"unterminated string\", quote + \" or \\\\\");\n\t\t\t\t} else {\n\t\t\t\t\tc = input.charAt(i++);\n\t\t\t\t\tif (c == '\\\\' || c == '\\'' || c == '\\\"') {\n\t\t\t\t\t\tbuilder.append(c);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new ScanException(position, \"invalid escape sequence \\\\\" + c, \"\\\\', \\\\\\\" or \\\\\\\\\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (c == quote) {\n\t\t\t\treturn token(Symbol.STRING, builder.toString(), i - position);\n\t\t\t} else {\n\t\t\t\tbuilder.append(c);\n\t\t\t}\n\t\t}\n\t\tthrow new ScanException(position, \"unterminated string\", String.valueOf(quote));\n\t}\n\t\n\t/**\n\t * number token\n\t */\n\tprotected Token nextNumber() throws ScanException {\n\t\tint i = position;\n\t\tint l = input.length();\n\t\twhile (i < l && isDigit(input.charAt(i))) {","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/de/odysseus/el/tree/impl/Scanner.java#L299-L335","documentation":"Scanner.nextString() throws ScanException('invalid escape sequence \\X') when a backslash inside a string literal is followed by a character other than backslash, single quote, or double quote. Only \\\\, \\', and \\\" are valid escapes; anything else is rejected at the position where the string started.","triggerScenarios":"A string literal inside an EL expression containing an escape like '\\n', '\\t', or '\\d' — e.g. \"${'a\\nb'}\" — because the scanner does not support those escapes.","commonSituations":"Developers copying regexes or Java string conventions (\\n, \\t, \\uXXXX) into EL string literals; expressions built by code that assumed Java-style escaping; regex patterns passed as EL strings.","solutions":["Replace unsupported escapes with the three supported ones (\\\\, \\', or \\\") or remove the backslash.","Use expression composition (concatenation, function calls) instead of escape sequences for special characters.","Precompute the desired string in Java/config and reference it as a variable instead of embedding escapes in EL."],"exampleFix":"// before\nString expr = \"${'line1\\nline2'}\"; // invalid \\n escape\n// after\nString expr = \"${'line1' + newLineVar + 'line2'}\";","handlingStrategy":"validation","validationCode":"private static final Pattern INVALID_ESCAPE = Pattern.compile(\"\\\\\\\\(?!['\\\\\\\\\\\\\\\"])\");\nboolean hasBadEscape(String expr) { return INVALID_ESCAPE.matcher(expr).find(); }","typeGuard":null,"tryCatchPattern":"try {\n    builder.build(expr);\n} catch (TreeBuilderException e) {\n    if (String.valueOf(e.getMessage()).startsWith(\"invalid escape sequence\")) {\n        throw new IllegalArgumentException(\"Only \\\\\\\\, \\\\' and \\\\\\\" escapes are allowed in EL strings: \" + expr);\n    }\n    throw e;\n}","preventionTips":["Remember EL strings support only \\\\, \\' and \\\" — no \\n/\\t/\\u escapes.","Pass special characters via variables/functions instead of escapes.","Regex-test literals in Java, not in EL strings.","Document escape rules where expressions are authored."],"tags":["el","scanner","escape-sequence","string-literal"],"backgroundTag":"invalid-escape-sequence","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}