Skip to content

Commit

Permalink
Don't recode ascii only strings
Browse files Browse the repository at this point in the history
  • Loading branch information
jhy committed Oct 20, 2023
1 parent 9de27fa commit f0eb6bd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/org/jsoup/helper/HttpConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -1145,11 +1145,13 @@ private static boolean looksLikeUtf8(byte[] input) {
}

int end;
boolean foundNonAscii = false;
for (int j = input.length; i < j; ++i) {
int o = input[i];
if ((o & 0x80) == 0) {
continue; // ASCII
}
foundNonAscii = true;

// UTF-8 leading:
if ((o & 0xE0) == 0xC0) {
Expand All @@ -1173,7 +1175,7 @@ private static boolean looksLikeUtf8(byte[] input) {
}
}
}
return true;
return foundNonAscii;
}

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

0 comments on commit f0eb6bd

Please sign in to comment.