Details
-
Enhancement
-
Resolution: Done
-
Major
-
None
-
None
-
None
Description
Media type parsing has some problems with double-quoted parameters:
- ; and , are interpreted as parameter/media type separator even when they occur in a quoted parameter value
- ' is interpreted as a quoting character, the spec says only " must be used for quoting
- Only spaces are allowed, not \t.
- Spaces are allowed in too many places, e.g. type / subtype or parameter = value
- Start and end quotes are removed from quoted parameter values, but the escaped characters inside are not unescaped.
- Quotes are not added back in toString(), which makes deserialization fail if one of the parameters included an escaped double-quote (e.g. type/subtype; param="\"").
Performance can also be improved, as we create many String instances via trim(), substring(), or split().
The clearest explanation of the media type grammar seems to be in
https://tools.ietf.org/html/rfc7231#section-3.1.1.1
https://tools.ietf.org/html/rfc7230#section-3.2.6