From 47cd9faf65bb021aa4541b45e373a8e40f195d88 Mon Sep 17 00:00:00 2001 From: Outfluencer <48880402+Outfluencer@users.noreply.github.com> Date: Sat, 20 Aug 2022 04:45:58 +0200 Subject: [PATCH] A char can be 3 bytes (#843) BungeeCord reference: https://github.com/SpigotMC/BungeeCord/pull/3377/commits/b5365dcba75f9350684cc30e87ef3a83f89d1326 --- .../com/velocitypowered/proxy/protocol/ProtocolUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/ProtocolUtils.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/ProtocolUtils.java index 59153c990..51cc7ff50 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/ProtocolUtils.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/ProtocolUtils.java @@ -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());