Skip to content

Commit 38ee3c6

Browse files
duonglaiquangrbri
authored andcommitted
EncodingSniffer: change meta tag parsing to case insensitive
1 parent 3899041 commit 38ee3c6

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/main/java/org/htmlunit/util/EncodingSniffer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,8 @@ else if (matches(bytes, i, META_START)) {
455455
i += META_START.length;
456456
for (Attribute att = getAttribute(bytes, i); att != null; att = getAttribute(bytes, i)) {
457457
i = att.getUpdatedIndex();
458-
final String name = att.getName();
459-
final String value = att.getValue();
458+
final String name = att.getName().toLowerCase(Locale.ROOT);
459+
final String value = att.getValue().toLowerCase(Locale.ROOT);
460460
if ("charset".equals(name) || "content".equals(name)) {
461461
Charset charset = null;
462462
if ("charset".equals(name)) {

src/test/java/org/htmlunit/util/EncodingSnifferTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public void fromMetaTag() throws Exception {
8080
meta(UTF_8, "abc <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>");
8181
meta(UTF_8, "abc <meta http-equiv='Content-Type' content='text/html; CHARSET=UTF-8'/>");
8282
meta(UTF_8, "abc <meta http-equiv='Content-Type' content='text/html; chArsEt=UtF-8'/>");
83+
meta(UTF_8, "<meta a='b' c=d e=\"f\" CONTENT='text/html; CHARSET=utf-8' />");
8384
}
8485

8586
private static void meta(final Charset expectedEncoding, final String content) throws Exception {

0 commit comments

Comments
 (0)