Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-94456

Chat converting NBSP (non-breaking space) to space causes glitches

XMLWordPrintable

    • Icon: Bug 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
    • 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:

      net.minecraft.network.NetHandlerPlayServer.processChatMessage(CPacketChatMessage)
          /**
           * 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.

        1. crash-2016-03-13_16.17.54-client.txt
          12 kB
        2. crash-2015-12-17_16.56.36-client.txt
          10 kB
        3. bug_3.png
          bug_3.png
          5.77 MB
        4. bug_2.png
          bug_2.png
          5.77 MB
        5. bug_1.png
          bug_1.png
          5.96 MB

            Unassigned Unassigned
            __null null (Inactive)
            Votes:
            6 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: