Skip to content

Charset appended to multipart parts regardless of the media type already specified #30262

Open

Description

Describe the bug

We use org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput parameter for a JAX-RS endpoint method that consumes multipart/form-data. When we fetch the media type of a part, it has always charset=UTF-8 specified, regardless of the media type that the client actually specified (so, we can get things like application/octet-stream; charset=UTF-8, which is absurd).

We tried to set quarkus.resteasy-reactive.multipart.input-part.default-charset to an empty value in application.properties, but this is not supported, there simply must be a valid Charset name, otherwise the container fails to start because of the value is not acceptable.

Anyway, we need to get the media type exactly as the client specified, so not having the option to suppress any default charset is quite a problem.

Expected behavior

It should be possible to specify no default charset at all, so that we can get the media type as actually specified by the client. It might be acceptable if the default charset is applied for types when it makes sense (probably just text/*).

Actual behavior

The endpoint receives the form data with the media type with the default charset specified always.

How to Reproduce?

import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType;
import org.jboss.resteasy.plugins.providers.multipart.InputPart;
import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput;

@Path("/test")
public final class TestEndpoint {

    @POST
    @Consumes(MediaType.MULTIPART_FORM_DATA)
    public void test(MultipartFormDataInput form) {
        final var parts = form.getParts();

        if (parts != null) {
            parts.stream().map(InputPart::getMediaType).forEach(System.out::println);
        }
    }
}

Send a multipart request then, e.g.:

curl -X POST \
-H 'content-type: multipart/form-data; boundary=f555d9c6-f40f-4d62-a217-f64a58d75b50' \
--data-raw '--f555d9c6-f40f-4d62-a217-f64a58d75b50
Content-Disposition: form-data; name="data"
Content-Type: application/octet-stream

ABC

--f555d9c6-f40f-4d62-a217-f64a58d75b50--
' http://localhost:8080/test

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.15.2

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    area/resteasy-classickind/bugSomething isn't workingtriage/upstreamUsed for issues which are caused by issues in upstream projects/dependency

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions