mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-02 17:32:03 +01:00
42 lines
2.3 KiB
Diff
42 lines
2.3 KiB
Diff
--- a/net/minecraft/resources/ResourceLocation.java
|
|
+++ b/net/minecraft/resources/ResourceLocation.java
|
|
@@ -32,6 +_,7 @@
|
|
public static final char NAMESPACE_SEPARATOR = ':';
|
|
public static final String DEFAULT_NAMESPACE = "minecraft";
|
|
public static final String REALMS_NAMESPACE = "realms";
|
|
+ public static final String PAPER_NAMESPACE = "paper"; // Paper
|
|
private final String namespace;
|
|
private final String path;
|
|
|
|
@@ -40,6 +_,13 @@
|
|
|
|
assert isValidPath(path);
|
|
|
|
+ // 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;
|
|
}
|
|
@@ -252,7 +_,7 @@
|
|
|
|
private static String assertValidNamespace(String namespace, String path) {
|
|
if (!isValidNamespace(namespace)) {
|
|
- throw new ResourceLocationException("Non [a-z0-9_.-] character in namespace of location: " + namespace + ":" + path);
|
|
+ throw new ResourceLocationException("Non [a-z0-9_.-] character in namespace of location: " + org.apache.commons.lang3.StringUtils.normalizeSpace(namespace) + ":" + org.apache.commons.lang3.StringUtils.normalizeSpace(path)); // Paper - Sanitize ResourceLocation error logging
|
|
} else {
|
|
return namespace;
|
|
}
|
|
@@ -277,7 +_,7 @@
|
|
|
|
private static String assertValidPath(String namespace, String path) {
|
|
if (!isValidPath(path)) {
|
|
- throw new ResourceLocationException("Non [a-z0-9/._-] character in path of location: " + namespace + ":" + path);
|
|
+ throw new ResourceLocationException("Non [a-z0-9/._-] character in path of location: " + namespace + ":" + org.apache.commons.lang3.StringUtils.normalizeSpace(path)); // Paper - Sanitize ResourceLocation error logging
|
|
} else {
|
|
return path;
|
|
}
|