{"record":{"id":"cda48646a29b6f59","repo":"quarkusio/quarkus","slug":"error-decoding-filename-attribute-wrapped-arrayi","errorCode":null,"errorMessage":"Error decoding filename* attribute (wrapped ArrayIndexOutOfBoundsException/UnsupportedCharsetException)","messagePattern":"Error decoding filename\\* attribute \\(wrapped ArrayIndexOutOfBoundsException/UnsupportedCharsetException\\)","errorType":"exception","errorClass":"ErrorDataDecoderException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/QuarkusMultipartResponseDecoder.java","lineNumber":850,"sourceCode":"        String name = cleanString(values[0]);\n        String value = values[1];\n\n        // Filename can be token, quoted or encoded. See https://tools.ietf.org/html/rfc5987\n        if (HttpHeaderValues.FILENAME.contentEquals(name)) {\n            // Value is quoted or token. Strip if quoted:\n            int last = value.length() - 1;\n            if (last > 0 &&\n                    value.charAt(0) == HttpConstants.DOUBLE_QUOTE &&\n                    value.charAt(last) == HttpConstants.DOUBLE_QUOTE) {\n                value = value.substring(1, last);\n            }\n        } else if (FILENAME_ENCODED.equals(name)) {\n            try {\n                name = HttpHeaderValues.FILENAME.toString();\n                String[] split = cleanString(value).split(\"'\", 3);\n                value = QueryStringDecoder.decodeComponent(split[2], Charset.forName(split[0]));\n            } catch (ArrayIndexOutOfBoundsException | UnsupportedCharsetException e) {\n                throw new ErrorDataDecoderException(e);\n            }\n        } else {\n            // otherwise we need to clean the value\n            value = cleanString(value);\n        }\n        return factory.createAttribute(response, name, value);\n    }\n\n    /**\n     * Get the FileUpload (new one or current one)\n     *\n     * @param delimiter\n     *        the delimiter to use\n     * @return the InterfaceHttpData if any\n     * @throws ErrorDataDecoderException on decoder error\n     */\n    protected InterfaceHttpData getFileUpload(String delimiter) {\n        // eventually restart from existing FileUpload","sourceCodeStart":832,"sourceCodeEnd":868,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/QuarkusMultipartResponseDecoder.java#L832-L868","documentation":"This ErrorDataDecoderException wraps ArrayIndexOutOfBoundsException or UnsupportedCharsetException raised while decoding an RFC 5987-style filename* (filename-encoded) disposition parameter. The value must look like charset'lang'%encoded-value; splitting on quotes requires exactly 3 segments, and the charset prefix must be a known charset. Malformed syntax or an unknown charset aborts the decode.","triggerScenarios":"A filename* parameter value does not have the charset'lang'value shape (fewer than 3 quote-separated segments -> ArrayIndexOutOfBoundsException) or declares a charset unknown to the JVM (Charset.forName throws -> UnsupportedCharsetException).","commonSituations":"Servers emitting filename* without the charset'' prefix (just the percent-encoded name); exotic charset labels like 'cp437' unavailable in some JVM distributions; middlewares stripping quotes incorrectly.","solutions":["Fix the server to emit the full RFC 5987 syntax: filename*=UTF-8''My%20File.txt.","Use a standard charset label (UTF-8, ISO-8859-1) in filename*.","If only the percent-encoded name is sent, switch the server to a plain filename parameter instead.","Keep filename ASCII-only so filename* is not needed at all."],"exampleFix":"// before (missing charset/lang segments)\nfilename*=My%20File.txt\n// after\nfilename*=UTF-8''My%20File.txt","handlingStrategy":"validation","validationCode":"// Validate RFC 5987 filename* syntax before sending\nPattern F = Pattern.compile(\"^[A-Za-z0-9-]+'[^']*'.+\");\nif (!F.matcher(filenameStar).matches() || !Charset.isSupported(filenameStar.split(\"'\")[0])) {\n    throw new IllegalStateException(\"filename* must be charset'lang'percent-encoded-value with a supported charset\");\n}","typeGuard":"static boolean isValidFilenameStar(String v) {\n    String[] parts = v == null ? new String[0] : v.split(\"'\", 3);\n    return parts.length == 3 && !parts[0].isBlank() && Charset.isSupported(parts[0]);\n}","tryCatchPattern":"try {\n    return decodeDisposition(name, value);\n} catch (ErrorDataDecoderException e) {\n    log.warn(\"filename* decode failed (cause={})\", e.getCause(), e);\n    return fallbackToPlainFilename(name, value); // e.g. use ASCII 'filename' instead\n}","preventionTips":["Always emit filename* as charset''percent-encoded-value (UTF-8''...).","Prefer plain ASCII filename to avoid filename* entirely.","Verify charset labels against Charset.isSupported for your target JVM.","Encode only the value segment; keep quotes count exactly two."],"tags":["multipart","filename","rfc5987","charset","resteasy-reactive"],"backgroundTag":"malformed-filename-encoding","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}