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

You can run commands with double slash prefix

    XMLWordPrintable

Details

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

    Description

      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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved:
              CHK: