Mojira Archive
MC-251762

You can run commands with double slash prefix

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.

Fixed

apple502j

[Mojang] Gegy

2022-05-15, 05:55 PM

2022-05-17, 02:08 PM

2022-05-17, 02:08 PM

2

3

Confirmed

Normal

Commands

22w19a

1.19 Pre-release 1