SPR-8697 Flag '*/subtype' as illegal.
This commit is contained in:
parent
e7377e3c27
commit
01cc76f8e3
|
@ -575,6 +575,9 @@ public class MediaType implements Comparable<MediaType> {
|
||||||
}
|
}
|
||||||
String type = fullType.substring(0, subIndex);
|
String type = fullType.substring(0, subIndex);
|
||||||
String subtype = fullType.substring(subIndex + 1, fullType.length());
|
String subtype = fullType.substring(subIndex + 1, fullType.length());
|
||||||
|
if (WILDCARD_TYPE.equals(type) && !WILDCARD_TYPE.equals(subtype)) {
|
||||||
|
throw new IllegalArgumentException("A wildcard type is legal only in '*/*' (all media types).");
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, String> parameters = null;
|
Map<String, String> parameters = null;
|
||||||
if (parts.length > 1) {
|
if (parts.length > 1) {
|
||||||
|
|
|
@ -128,6 +128,11 @@ public class MediaTypeTests {
|
||||||
MediaType.parseMediaType("audio/");
|
MediaType.parseMediaType("audio/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
public void parseMediaTypeTypeRange() {
|
||||||
|
MediaType.parseMediaType("*/json");
|
||||||
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
public void parseMediaTypeIllegalType() {
|
public void parseMediaTypeIllegalType() {
|
||||||
MediaType.parseMediaType("audio(/basic");
|
MediaType.parseMediaType("audio(/basic");
|
||||||
|
|
Loading…
Reference in New Issue