Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 458126

Summary: Parse multipart/form-data before it enters the servlet
Product: [RT] Jetty Reporter: Jan Bartel <janb>
Component: serverAssignee: Jan Bartel <janb>
Status: CLOSED MOVED QA Contact:
Severity: normal    
Priority: P3 CC: bill.mair, jesse.mcconnell, jetty-inbox
Version: 9.3.0   
Target Milestone: 9.2.x   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on: 455655    
Bug Blocks:    

Description Jan Bartel CLA 2015-01-22 07:18:16 EST
As reported in https://bugs.eclipse.org/bugs/show_bug.cgi?id=455655 there is a problem reporting parsing errors of multipart/form-data to the servlet. Jetty-9.2 was modified to throw runtime exceptions when the servlet attempts to retrieve the parts with any of the getPart/Parts methods. 

The solution for jetty-9.3 may be to throw any exception much earlier in the request processing, so that servlet is not even entered if there is a serious formatting error in the multipart data.
Comment 1 Bill Mair CLA 2015-01-22 09:39:13 EST
It should be possible to register a factory to create parser instances that parse "multipart/form-data" (e.g. MultiPartInputStreamParser and MultiPartInputStreamParserFactory).

The current implementation should be changed to implement the interface and if no Factory has been registered by the servlet then the default implementation should be used.

This would allow servlets to parse and verify the data and compensate for erroneous input.

Maybe some kind of Content-Type based request processor registration already exists?
Comment 2 Jesse McConnell CLA 2016-02-17 09:32:41 EST
https://github.com/eclipse/jetty.project/issues/182