Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-3128

struts2-rest-plugin incorrectly handles multipart/form-data content-type data

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.6
    • Fix Version/s: 2.1.8
    • Component/s: Plugin - REST
    • Labels:
      None
    • Flags:
      Patch

      Description

      When a POST request is made with "multipart/form-data" encoding, such as to upload a file, the "DefaultContentTypeHandlerManager" has no custom input handler registered to handle "multipart/form-data" data. The plugin assumes a default input handler based on the request extension. In case of "xml" (which is also the default handler failing all else), the handler attempts to parse the payload as xml, which results in an exception being thrown.

      The solution is to write a custom content-type handler similar to the "FormUrlEncodedHandler" that ignores the form payload. In addition, the "DefaultContentTypeHandlerManager" needs to be modified, since the content-type of the form data is not actually "multipart/form-data", but rather ""multipart/form-data; boundary=abcdefg". Simple parsing is done to remove the additional parameters of the content-type so that the proper handler can be correctly resolved.

        Attachments

          Activity

            People

            • Assignee:
              wesw@wantii.com Wes Wannemacher
              Reporter:
              bdferris Brian Ferris
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: