forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Improve handling of broken accept headers in MediaTypeHeaderDele…
…gate.parse(..) within resteasy-reactive Previously, a "broken" MIME-type in an access header could trigger an StringIndexOutOfBoundsException during MediaTypeHeaderDelegate.parse(..) instead of the more suitable IllegalArgumentException. Example: "Accept: x; /x" This PR now throws an IllegalArgumentException in case of a broken MIME-type like in the example. Fixes quarkusio#36159 (cherry picked from commit 84d6c5d)
- Loading branch information
1 parent
3dc0261
commit edb5a19
Showing
2 changed files
with
24 additions
and
0 deletions.
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
21 changes: 21 additions & 0 deletions
21
...src/test/java/org/jboss/resteasy/reactive/common/headers/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,21 @@ | ||
package org.jboss.resteasy.reactive.common.headers; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class MediaTypeHeaderDelegateTest { | ||
|
||
public void parsingBrokenMediaTypeShouldThrowIllegalArgumentException_minimized() { | ||
Assertions.assertThrows(IllegalArgumentException.class, () -> { | ||
MediaTypeHeaderDelegate.parse("x; /x"); | ||
}); | ||
} | ||
|
||
@Test | ||
public void parsingBrokenMediaTypeShouldThrowIllegalArgumentException_actual() { | ||
Assertions.assertThrows(IllegalArgumentException.class, () -> { | ||
MediaTypeHeaderDelegate.parse("() { ::}; echo \"NS:\" $(/bin/sh -c \"expr 123456 - 123456\")"); | ||
}); | ||
} | ||
|
||
} |