This commit is contained in:
Reinhard Pointner 2014-04-01 19:56:37 +00:00
parent 3802cc6965
commit 37d8c1f63e
1 changed files with 2 additions and 2 deletions

View File

@ -233,13 +233,13 @@ public final class WebRequest {
private static Charset getCharset(String contentType) { private static Charset getCharset(String contentType) {
if (contentType != null) { if (contentType != null) {
// e.g. Content-Type: text/html; charset=iso-8859-1 // e.g. Content-Type: text/html; charset=iso-8859-1
Matcher matcher = Pattern.compile("charset=(\\p{Graph}+)").matcher(contentType); Matcher matcher = Pattern.compile("charset=[\"]?([\\p{Graph}&&[^\"]]+)[\"]?").matcher(contentType);
if (matcher.find()) { if (matcher.find()) {
try { try {
return Charset.forName(matcher.group(1)); return Charset.forName(matcher.group(1));
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Logger.getLogger(WebRequest.class.getName()).log(Level.WARNING, e.getMessage()); Logger.getLogger(WebRequest.class.getName()).log(Level.WARNING, "Illegal charset: " + contentType);
} }
} }