Created
July 18, 2012 11:08
-
-
Save anonymous/3135601 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -r de960161c5f1 src/nu/validator/xml/ContentTypeParser.java | |
--- a/src/nu/validator/xml/ContentTypeParser.java Thu Jul 21 17:58:26 2011 +0300 | |
+++ b/src/nu/validator/xml/ContentTypeParser.java Wed Jul 18 20:15:01 2012 +0900 | |
@@ -34,8 +34,8 @@ | |
public class ContentTypeParser { | |
- private static final Pattern CHARSET = Pattern.compile("^\\s*charset\\s*=\\s*(\\S+)\\s*$"); | |
- | |
+ private static final Pattern CHARSET = Pattern.compile("^\\s*charset\\s*=\\s*(?:\"([^\"\\s]+)\")|([^\"\\s]+)\\s*$"); | |
+ | |
private final ErrorHandler errorHandler; | |
private boolean laxContentType; | |
@@ -209,7 +209,11 @@ | |
for (int i = 1; i < params.length; i++) { | |
Matcher matcher = CHARSET.matcher(params[i]); | |
if (matcher.matches()) { | |
- charset = matcher.group(1); | |
+ if (matcher.start(1) != -1) { | |
+ charset = matcher.group(1); | |
+ } else { | |
+ charset = matcher.group(2); | |
+ } | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment