SPR-8697 Flag '*/subtype' as illegal.

This commit is contained in:
Rossen Stoyanchev 2011-11-17 20:15:49 +00:00
parent e7377e3c27
commit 01cc76f8e3
2 changed files with 8 additions and 0 deletions

View File

@ -575,6 +575,9 @@ public class MediaType implements Comparable<MediaType> {
}
String type = fullType.substring(0, subIndex);
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;
if (parts.length > 1) {

View File

@ -128,6 +128,11 @@ public class MediaTypeTests {
MediaType.parseMediaType("audio/");
}
@Test(expected = IllegalArgumentException.class)
public void parseMediaTypeTypeRange() {
MediaType.parseMediaType("*/json");
}
@Test(expected = IllegalArgumentException.class)
public void parseMediaTypeIllegalType() {
MediaType.parseMediaType("audio(/basic");