-
Bug
-
Resolution: Done
-
Minor
-
4.7.9.Final, 5.0.8.Final, 6.2.5.Final
-
None
Processing an HTTP Request with a malformed accept header fails with a HTTP Status 500 (Internal Server Error) instead of 400 (Bad request).
Reason is that the MediaType parsing in org.jboss.resteasy.plugins.delegates.MediaTypeHeaderDelegate#internalParse throws an StringIndexOutOfBoundException which bubbles up the stack instead of wrapping it in an IllegalArgumentException.
The following test triggers the wrong exception:
package org.jboss.resteasy.plugins.delegates; import org.junit.Test; public class MediaTypeHeaderDelegateTest { @Test public void parseBrokenMediaTypeShouldThrowIllegalArgumentException_minimized() { MediaTypeHeaderDelegate.parse("x; /x"); } @Test public void parseBrokenMediaTypeShouldThrowIllegalArgumentException_actual() { MediaTypeHeaderDelegate.parse("() { ::}; echo \"NS:\" $(/bin/sh -c \"expr 123456 - 123456\")"); } }