Skip to content

Commit f0eb6bd

Browse files
committed
Don't recode ascii only strings
1 parent 9de27fa commit f0eb6bd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/main/java/org/jsoup/helper/HttpConnection.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,11 +1145,13 @@ private static boolean looksLikeUtf8(byte[] input) {
11451145
}
11461146

11471147
int end;
1148+
boolean foundNonAscii = false;
11481149
for (int j = input.length; i < j; ++i) {
11491150
int o = input[i];
11501151
if ((o & 0x80) == 0) {
11511152
continue; // ASCII
11521153
}
1154+
foundNonAscii = true;
11531155

11541156
// UTF-8 leading:
11551157
if ((o & 0xE0) == 0xC0) {
@@ -1173,7 +1175,7 @@ private static boolean looksLikeUtf8(byte[] input) {
11731175
}
11741176
}
11751177
}
1176-
return true;
1178+
return foundNonAscii;
11771179
}
11781180

11791181
private @Nullable static String setOutputContentType(final Connection.Request req) {

0 commit comments

Comments
 (0)