quarkusio/quarkus · warning · BadRequestException

Extra characters after quoted string:

Error message

Extra characters after quoted string:

What it means

After a quoted parameter value ends, parseParameters() checks the remaining text up to the end of the header. If non-whitespace characters remain after the closing quote, this BadRequestException is thrown.

Source

Thrown at independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/request/AcceptHeaders.java:190

            offset = equalsIndex + 1;
            if (header.charAt(offset) == '"') {
                int end = offset;
                ++offset;
                do {
                    end = header.indexOf('"', ++end);
                    if (end < 0)
                        throw new BadRequestException("Unclosed quotes:" + header);
                } while (header.charAt(end - 1) == '\\');
                String value = header.substring(offset, end);
                parameters.put(name, value);
                offset = end + 1;

                int parameterEndIndex = header.indexOf(';', offset);
                int itemEndIndex = header.indexOf(',', offset);
                if (parameterEndIndex == itemEndIndex) {
                    assert itemEndIndex == -1;
                    if (header.substring(offset).trim().length() != 0)
                        throw new BadRequestException("Extra characters after quoted string:" + header);
                    return -1;
                } else if (parameterEndIndex < 0 || (itemEndIndex >= 0 && itemEndIndex < parameterEndIndex)) {
                    if (header.substring(offset, itemEndIndex).trim().length() != 0)
                        throw new BadRequestException("Extra characters after quoted string:" + header);
                    return itemEndIndex + 1;
                } else {
                    if (header.substring(offset, parameterEndIndex).trim().length() != 0)
                        throw new BadRequestException("Extra characters after quoted string:" + header);
                    offset = parameterEndIndex + 1;
                }
            } else {
                int parameterEndIndex = header.indexOf(';', offset);
                int itemEndIndex = header.indexOf(',', offset);
                if (parameterEndIndex == itemEndIndex) {
                    assert itemEndIndex == -1;
                    String value = header.substring(offset).trim();
                    parameters.put(name, value);
                    return -1;

View on GitHub (pinned to e1c734241f)

Solutions

  1. Remove stray characters between the closing quote and the next ';' or ',' or end of header
  2. Fix header-building code so quoted values are followed by a delimiter
  3. Verify no proxy or interceptor mangles the header

Example fix

// before
Accept: application/json;x="v"junk
// after
Accept: application/json;x="v"
Defensive patterns

Strategy: validation

Validate before calling

java.util.regex.Pattern QUOTED_PARAM = java.util.regex.Pattern.compile("\\w+=\"[^\"]*\"");
boolean noTrailingJunk(String header) {
    return header == null || QUOTED_PARAM.split(header, 2).length < 2;
}

Try / catch

try {
    types = AcceptHeaders.getMediaTypeQualityValues(accept);
} catch (BadRequestException e) {
    types = Collections.emptyMap();
}

Prevention

When it happens

Trigger: Header like 'application/json;x="v"junk' — characters after the quoted value that are neither ';' nor a valid terminator.

Common situations: Typos in hand-written headers; string-building bugs appending text after quoted values; proxies rewriting quoted parameter values.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/ef115581e80728ba. Report an issue: GitHub.