jersey
  1. jersey
  2. JERSEY-1900

FormParamValueFactoryProvider getFormParameters fails when Content-Type header includes media type and charset

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-rc1
    • Fix Version/s: 2.2
    • Component/s: core
    • Labels:
      None

      Description

      When the Content-Type header includes charset (ex: application/x-www-form-urlencoded; charset=UTF-8) then FormParamValueFactoryProvider has a problem in getFormParameters:

      private Form getFormParameters(ContainerRequest requestContext) {
          if (requestContext.getMediaType().equals(MediaType.APPLICATION_FORM_URLENCODED_TYPE)) {
              requestContext.bufferEntity();
              Form form;
              if (decode) {
                  form = requestContext.readEntity(Form.class);
              else {
                  Annotation[] annotations = new Annotation[1];
                  annotations[0] = encodedAnnotation;
                  form = requestContext.readEntity(Form.class, annotations);
              }
      
              return (form == null ? new Form() : form);
          } else {
              return new Form();
          }
      }
      

      (https://github.com/jersey/jersey/blob/master/core-server/src/main/java/org/glassfish/jersey/server/internal/inject/FormParamValueFactoryProvider.java#L194)

      The first if statement uses the MediaType.equals method which compares type, subtype, and parameters (charset is a parameter) resulting in an empty Form object being returned.

        Activity

        Hide
        Michal Gajdos added a comment -

        Fixed in 2.2. See test-case FormParamTest.testSimpleFormResourceWithCharset.

        Show
        Michal Gajdos added a comment - Fixed in 2.2. See test-case FormParamTest.testSimpleFormResourceWithCharset .

          People

          • Assignee:
            Michal Gajdos
            Reporter:
            adrianluisgonzalez
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: