-
Bug
-
Resolution: Cannot Reproduce
-
None
-
Minecraft 1.8.9, Minecraft 15w51b, Minecraft 1.9, Minecraft 1.9.1 Pre-Release 3, Minecraft 1.9.1, Minecraft 1.9.2, Minecraft 16w14a, Minecraft 16w15b, Minecraft 1.9.3 Pre-Release 1, Minecraft 1.9.3 Pre-Release 3, Minecraft 1.9.4, Minecraft 16w20a, Minecraft 16w21a, Minecraft 16w21b, Minecraft 1.10 Pre-Release 1, Minecraft 1.10 Pre-Release 2, Minecraft 1.10, Minecraft 1.10.1, Minecraft 1.10.2, Minecraft 16w35a, Minecraft 16w40a, Minecraft 1.11, Minecraft 1.11.2, Minecraft 17w06a, Minecraft 17w15a, Minecraft 1.12 Pre-Release 6, Minecraft 1.12 Pre-Release 7, Minecraft 1.12, Minecraft 1.12.1 Pre-Release 1, Minecraft 17w43a, Minecraft 17w43b, Minecraft 17w45b, Minecraft 18w03b, Minecraft 18w11a, Minecraft 18w21b, Minecraft 1.13-pre2, Minecraft 1.13-pre3, Minecraft 1.13, Minecraft 18w30b, Minecraft 1.13.1, Minecraft 18w43c, Minecraft 18w45a, Minecraft 19w07a, Minecraft 1.14 Pre-Release 2, Minecraft 1.14.1 Pre-Release 1, 19w37a, 1.16.4, 1.16.5
-
Operating System: Mac OS X (x86_64) version 10.11.2
Java Version: 1.8.0_60, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 619978928 bytes (591 MB) / 920649728 bytes (878 MB) up to 920649728 bytes (878 MB)
JVM Flags: 3 total; -Xms1G -Xmx1G -Xmn512M
IntCache: cache: 1, tcache: 1, allocated: 12, tallocated: 94
Launched Version: 15w51b
LWJGL: 2.9.2
OpenGL: AMD Radeon R9 M290 OpenGL Engine GL version 2.1 ATI-1.40.15, ATI Technologies Inc.
GL Caps: Using GL 1.3 multitexturing.Operating System: Mac OS X (x86_64) version 10.11.2 Java Version: 1.8.0_60, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 619978928 bytes (591 MB) / 920649728 bytes (878 MB) up to 920649728 bytes (878 MB) JVM Flags: 3 total; -Xms1G -Xmx1G -Xmn512M IntCache: cache: 1, tcache: 1, allocated: 12, tallocated: 94 Launched Version: 15w51b LWJGL: 2.9.2 OpenGL: AMD Radeon R9 M290 OpenGL Engine GL version 2.1 ATI-1.40.15, ATI Technologies Inc. GL Caps: Using GL 1.3 multitexturing.
-
Community Consensus
-
(Unassigned)
When non-breaking space characters (U+00A0) are sent in chat, they are converted to space characters. However, spaces are cleaned up (removed at the beginning and end, etc.) before this conversion, meaning that NBSPs can be used to bypass it.
Examples: ("#" means a NBSP character)
- a##########b##########c creates a lot of spaces between a, b, and c
#####abc creates a lot of spaces before the chat message "abc"(Since sometime between 17w06a and 17w15a, Minecraft now removes NBSPs at the beginning of the message)- # creates a "blank" chat message containing only a space
The cause
Decompiled via MCP 9.24 beta:
/** * Process chat messages (broadcast back to clients) and commands (executes) */ public void processChatMessage(CPacketChatMessage packetIn) { // ... else { this.playerEntity.markPlayerActive(); String s = packetIn.getMessage(); s = StringUtils.normalizeSpace(s); // <- here // ... } }
net.minecraft.network.NetHandlerPlayServer.processChatMessage(CPacketChatMessage) calls org.apache.commons.lang3.StringUtils.normalizeSpace(String), which uses its WHITESPACE_PATTERN.
Mojang can fix this by first replacing all NBSP with spaces via s.replace('\u00A0', ' ') (though it is kind of hacky), or by using their own pattern instead of Apache's WHITESPACE_PATTERN.
Original description
Copy-pasting non-breaking space characters (or using Opt-Space on a Mac) into chat causes them to be converted into normal spaces when the chat message is sent. However, this can cause bugs as they can be stringed together to create multiple spaces in a row, something that is not possible with regular spaces. Also, this can be used to send "blank" chat messages (only a space).
A way to fix:
It seems to me that the game first changes all double-spaces to single space characters, then checks if the message is empty, and then converts non-breaking spaces to spaces.
To fix the issue, the game should first convert non-breaking spaces to spaces, then change double-spaces to single spaces and check if the message is empty.
Possibly not a minecraft bug, see this comment.