-
Notifications
You must be signed in to change notification settings - Fork 889
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RESTEASY-3384] Improve parsing of malformed MediaTypes in MediaTypeH…
…eaderDelegate Previously, a "broken" MIME-type could trigger an StringIndexOutOfBoundsException instead of the more suitable IllegalArgumentException. Example: "Accept: x; /x" This PR now throws an IllegalArgumentException in case of a broken MIME-type.
- Loading branch information
1 parent
936c563
commit d493a85
Showing
2 changed files
with
21 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...-core/src/test/java/org/jboss/resteasy/plugins/delegates/MediaTypeHeaderDelegateTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.jboss.resteasy.plugins.delegates; | ||
|
||
import org.junit.Test; | ||
|
||
public class MediaTypeHeaderDelegateTest { | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void parsingBrokenMediaTypeShouldThrowIllegalArgumentException_minimized() { | ||
MediaTypeHeaderDelegate.parse("x; /x"); | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void parsingBrokenMediaTypeShouldThrowIllegalArgumentException_actual() { | ||
MediaTypeHeaderDelegate.parse("() { ::}; echo \"NS:\" $(/bin/sh -c \"expr 123456 - 123456\")"); | ||
} | ||
} |