3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-09-29 06:30:16 +02:00

A char can be 3 bytes (#843)

BungeeCord reference: b5365dcba7
Dieser Commit ist enthalten in:
Outfluencer 2022-08-20 04:45:58 +02:00 committet von GitHub
Ursprung 4b33d5fb8a
Commit 47cd9faf65
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -185,9 +185,9 @@ public enum ProtocolUtils {
private static String readString(ByteBuf buf, int cap, int length) {
checkFrame(length >= 0, "Got a negative-length string (%s)", length);
// `cap` is interpreted as a UTF-8 character length. To cover the full Unicode plane, we must
// consider the length of a UTF-8 character, which can be up to 4 bytes. We do an initial
// consider the length of a UTF-8 character, which can be up to 3 bytes. We do an initial
// sanity check and then check again to make sure our optimistic guess was good.
checkFrame(length <= cap * 4, "Bad string size (got %s, maximum is %s)", length, cap);
checkFrame(length <= cap * 3, "Bad string size (got %s, maximum is %s)", length, cap);
checkFrame(buf.isReadable(length),
"Trying to read a string that is too long (wanted %s, only have %s)", length,
buf.readableBytes());