Also check for the actual character length in ResourceLocation validation
This commit is contained in:
@@ -29,7 +29,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
private final String path;
|
||||
|
||||
protected ResourceLocation(String namespace, String path, @Nullable ResourceLocation.Dummy extraData) {
|
||||
+ if (io.netty.buffer.ByteBufUtil.utf8MaxBytes(namespace + ":" + path) > 2 * Short.MAX_VALUE + 1) throw new ResourceLocationException("Resource location too long: " + namespace + ":" + path); // Paper - Validate ResourceLocation
|
||||
+ // Paper start - Validate ResourceLocation
|
||||
+ // Check for the max network string length (capped at Short.MAX_VALUE) as well as the max bytes of a StringTag (length written as an unsigned short)
|
||||
+ final String resourceLocation = namespace + ":" + path;
|
||||
+ if (resourceLocation.length() > Short.MAX_VALUE || io.netty.buffer.ByteBufUtil.utf8MaxBytes(resourceLocation) > 2 * Short.MAX_VALUE + 1) {
|
||||
+ throw new ResourceLocationException("Resource location too long: " + resourceLocation);
|
||||
+ }
|
||||
+ // Paper end - Validate ResourceLocation
|
||||
this.namespace = namespace;
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user