提交 01cc76f8 编写于 作者: R Rossen Stoyanchev

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

上级 e7377e3c
......@@ -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) {
......
......@@ -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");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册