Allow parsing of media types with single-quotes

Previously MediaType could only parse double-quoted parameters without
raising an IllegalArgumentException. Now parameters can also be
single-quoted.

Issue: SPR-8917
This commit is contained in:
Maxim Valyanskiy
2012-06-14 08:25:10 +04:00
committed by Rossen Stoyanchev
parent ab4952a959
commit 7cdc53487d
2 changed files with 14 additions and 1 deletions

View File

@@ -376,7 +376,12 @@ public class MediaType implements Comparable<MediaType> {
}
private boolean isQuotedString(String s) {
return s.length() > 1 && s.startsWith("\"") && s.endsWith("\"") ;
if (s.length() < 2) {
return false;
}
else {
return ((s.startsWith("\"") && s.endsWith("\"")) || (s.startsWith("'") && s.endsWith("'")));
}
}
private String unquote(String s) {