Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash method with translations when opening containers (server crash) or books (client crash) #142

Open
Zailer43 opened this issue Apr 17, 2024 · 0 comments

Comments

@Zailer43
Copy link

Zailer43 commented Apr 17, 2024

Details

The following NBT of a container can cause a java.lang.OutOfMemoryError: Java heap space. Therefore, this is prevented in the Name of the items on display, but it is not checked in the CustomName of the BlockEntityTag.

if (display.hasKeyOfType("Name", NbtDataType.STRING)) {
String name = display.getString("Name");
// check for Json array
if (name.startsWith("[{")) {
try {
JsonElement jsonElement = PARSER.parse(name);
JsonArray jsonArray = jsonElement.getAsJsonArray();
name = createTextFromJsonArray(jsonArray);
} catch (Exception e) {
// could not parse Json
}
}
// check for Json object
else if (name.startsWith("{")) {
try {
JsonElement jsonElement = PARSER.parse(name);
JsonObject jsonObject = jsonElement.getAsJsonObject();
JsonArray jsonArray = jsonObject.getAsJsonArray("extra");
if (jsonArray != null) {
name = createTextFromJsonArray(jsonArray);
}
} catch (Exception e) {
// could not parse Json
return NbtCheckResult.CRITICAL; // can cause crashes
}
}
final int maxNameLength;
// if strict, use anvil length
if (panilla.getPConfig().strictness.ordinal() >= PStrictness.STRICT.ordinal()) {
maxNameLength = panilla.getProtocolConstants().maxAnvilRenameChars();
} else {
maxNameLength = panilla.getProtocolConstants().NOT_PROTOCOL_maxItemNameLength();
}
if (name.length() > maxNameLength) {
return NbtCheckResult.CRITICAL; // can cause crashes
}
}

Edit: I was testing, and currently, Panilla doesn't fix it in books either, only in the item name

NBT

{BlockEntityTag: {CustomName: '[{"t\\u0072a\\u006es\\u006ca\\u0074e":"%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073","w\\u0069t\\u0068":["",[{"t\\u0072a\\u006es\\u006ca\\u0074e":"%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073","w\\u0069t\\u0068":["",[{"t\\u0072a\\u006es\\u006ca\\u0074e":"%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073","w\\u0069t\\u0068":["",[{"t\\u0072a\\u006es\\u006ca\\u0074e":"%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073","w\\u0069t\\u0068":["",[{"t\\u0072a\\u006es\\u006ca\\u0074e":"%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073","w\\u0069t\\u0068":["",[{"t\\u0072a\\u006es\\u006ca\\u0074e":"%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073","w\\u0069t\\u0068":["",[{"t\\u0072a\\u006es\\u006ca\\u0074e":"%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073","w\\u0069t\\u0068":["",[{"t\\u0072a\\u006es\\u006ca\\u0074e":"%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073","w\\u0069t\\u0068":["",[{"t\\u0072a\\u006es\\u006ca\\u0074e":"%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073","w\\u0069t\\u0068":["",[{"t\\u0072a\\u006es\\u006ca\\u0074e":"%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073","w\\u0069t\\u0068":["",[{"t\\u0072a\\u006es\\u006ca\\u0074e":"%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073","w\\u0069t\\u0068":["","overwritelox"]}]]}]]}]]}]]}]]}]]}]]}]]}]]}]]}]'}}
{BlockEntityTag: {CustomName: "[{\"translate\":\"%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s\",\"with\":[\"\",[{\"translate\":\"%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s\",\"with\":[\"\",[{\"translate\":\"%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s\",\"with\":[\"\",[{\"translate\":\"%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s\",\"with\":[\"\",[{\"translate\":\"%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s\",\"with\":[\"\",[{\"translate\":\"%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s\",\"with\":[\"\",[{\"translate\":\"%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s\",\"with\":[\"\",[{\"translate\":\"%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s\",\"with\":[\"\",[{\"translate\":\"%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s\",\"with\":[\"\",[{\"translate\":\"%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s\",\"with\":[\"\",[{\"translate\":\"%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s%2$s\",\"with\":[\"\",\"overwritelox\"]}]]}]]}]]}]]}]]}]]}]]}]]}]]}]]}]"}}

Edit: Book

/give @s minecraft:written_book{pages:['[{"t\\u0072a\\u006es\\u006ca\\u0074e":"%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073","w\\u0069t\\u0068":["",[{"t\\u0072a\\u006es\\u006ca\\u0074e":"%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073","w\\u0069t\\u0068":["",[{"t\\u0072a\\u006es\\u006ca\\u0074e":"%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073","w\\u0069t\\u0068":["",[{"t\\u0072a\\u006es\\u006ca\\u0074e":"%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073","w\\u0069t\\u0068":["",[{"t\\u0072a\\u006es\\u006ca\\u0074e":"%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073","w\\u0069t\\u0068":["",[{"t\\u0072a\\u006es\\u006ca\\u0074e":"%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073","w\\u0069t\\u0068":["",[{"t\\u0072a\\u006es\\u006ca\\u0074e":"%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073","w\\u0069t\\u0068":["",[{"t\\u0072a\\u006es\\u006ca\\u0074e":"%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073","w\\u0069t\\u0068":["",[{"t\\u0072a\\u006es\\u006ca\\u0074e":"%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073","w\\u0069t\\u0068":["",[{"t\\u0072a\\u006es\\u006ca\\u0074e":"%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073","w\\u0069t\\u0068":["",[{"t\\u0072a\\u006es\\u006ca\\u0074e":"%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073%\\u0032$\\u0073","w\\u0069t\\u0068":["","overwritelox"]}]]}]]}]]}]]}]]}]]}]]}]]}]]}]]}]'],title:"haha funny book", author:"Notch"}
@Zailer43 Zailer43 changed the title Crash method when opening containers with CustomName Crash method with translations when opening containers (server crash) or books (client crash) Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant