mojira.dev
MC-139908

Criterion names in advancement selector argument limited to unquoted strings

The bug

In entity selectors, the advancement selector has support for testing that certain criteria are set or unset. When parsing the selector, these can only be parsed successfully if they are made up of a limited subset of characters.

How to reproduce

Attempt to run either of the following two commands:

/execute if entity @s[advancements={minecraft:adventure/adventuring_time={"minecraft:bamboo_jungle_hills"=true}}]
/execute if entity @s[advancements={minecraft:adventure/adventuring_time={minecraft:bamboo_jungle_hills=true}}]

Expected behavior

There should not be a parsing error. For example, the following the following similar command parses successfully.

/execute if entity @s[advancements={minecraft:adventure/ol_betsy={shot_crossbow=true}}]

Actual behavior

There is a parsing error (Expected "=")

Code analysis

Based on MC version 18w47a, decompiled with CFR version 131.

The bug is in ea.java, soon after the string "advancements" is used (this is one of only four references to the string "advancements" in the entire codebase decompiled from the client jar). The following is an excerpt from the second (nested in the first) while loop:

while (stringReader.canRead() && stringReader.peek() != '}') {
    stringReader.skipWhitespace();
    String string = stringReader.readUnquotedString();
    stringReader.skipWhitespace();
    stringReader.expect('=');
    stringReader.skipWhitespace();
    // <...>
}

To fix this bug, the third line should call StringReader::readString as opposed to the current StringReader::readUnquotedString, which would support quoted strings and hence a wider array of the supported characters.

Linked issues

Comments 23

Confirmed for 1.19.3 and 1.19.4-rc3.
Seeing as Levertion has no activity since 2018, I'd like to request ownership of this report.

Hi, still present in 24w45a for 1.21.4, 6 years after the initial report.

When is this gonna be fixed? With Mojang putting a "minecraft:" in all requirements of vanilla advancements, it has become totally impossible to target players with a specific criteria...

Levertion

user-f2760

(Unassigned)

Confirmed

Platform

Low

Commands

Minecraft 1.13.2, Minecraft 18w47a, Minecraft 19w09a, Minecraft 19w11b, Minecraft 19w12a, ..., 1.19.4 Release Candidate 3, 1.19.4, 1.20.1, 1.20.2, 23w43b

Retrieved