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

You can run commands with double slash prefix

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 1.19 Pre-release 1
    • 22w19a
    • None
    • Confirmed
    • Commands
    • Normal

      Commands can be run with double slash prefix, e.g. //summon pig.

      Steps to Reproduce:
      1. Type //summon pig in chat
      2. Press Enter

      Observed Results:
      Pig gets summoned

      Expected Results:
      Command errors

      Code Analysis
      22w19a split the methods used to send the command and the chat message. Client sends the unslashed command:

      ChatScreen.java
        public void method_44056(String string, boolean bl) {
          /* omitted */
          if (string.startsWith("/")) {
            this.client.player.method_44098(string.substring(1), lv);
          } else {
            this.client.player.method_44096(string, lv);
          } 
        }
      

      However the server also removes the slash prefix:

      CommandManager.java
        public int execute(ServerCommandSource commandSource, String command) {
          StringReader stringReader = new StringReader(command);
          if (stringReader.canRead() && stringReader.peek() == '/')
            stringReader.skip(); 
          /* omitted */
        }
      

      therefore making the double-slashed command valid.

            gegy1000 [Mojang] Gegy
            apple502j apple502j
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: