aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatt Baxter <[email protected]>2020-08-17 13:13:15 -0400
committerGitHub <[email protected]>2020-08-17 10:13:15 -0700
commit60a5ca6d7dacb1e4c8e5f24160966bef361a7f25 (patch)
treeffdead43232269a9460c023b2f206c170f07701a
parent2b4ce0b370f2697616c4c73dbb42cd3d749b73c9 (diff)
downloadPaper-60a5ca6d7dacb1e4c8e5f24160966bef361a7f25.tar.gz
Paper-60a5ca6d7dacb1e4c8e5f24160966bef361a7f25.zip
Fix regex mistake in CB NBT int deserialization (#4146)
The existing regex is too open and allows for the absence of any actual number data, detecting an NBT entry of just the letter "i" in upper or lower case. This causes a single-character NBT entry to be processed as an integer ending in "i", passing an empty String to to Integer.parseInt, triggering an exception in loading the item. This commit forces numbers to be present prior to the ending "i" letter.
-rw-r--r--Spigot-Server-Patches/0552-Fix-regex-mistake-in-CB-NBT-int-deserialization.patch27
1 files changed, 27 insertions, 0 deletions
diff --git a/Spigot-Server-Patches/0552-Fix-regex-mistake-in-CB-NBT-int-deserialization.patch b/Spigot-Server-Patches/0552-Fix-regex-mistake-in-CB-NBT-int-deserialization.patch
new file mode 100644
index 0000000000..dae6898e5b
--- /dev/null
+++ b/Spigot-Server-Patches/0552-Fix-regex-mistake-in-CB-NBT-int-deserialization.patch
@@ -0,0 +1,27 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: mbax <[email protected]>
+Date: Mon, 17 Aug 2020 12:17:37 -0400
+Subject: [PATCH] Fix regex mistake in CB NBT int deserialization
+
+The existing regex is too open and allows for the absence of any actual
+number data, detecting an NBT entry of just the letter "i" in upper or
+lower case. This causes a single-character NBT entry to be processed as
+an integer ending in "i", passing an empty String to to Integer.parseInt,
+triggering an exception in loading the item.
+
+This commit forces numbers to be present prior to the ending "i"
+letter.
+
+diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftNBTTagConfigSerializer.java b/src/main/java/org/bukkit/craftbukkit/util/CraftNBTTagConfigSerializer.java
+index b17faa25e6db28e8538cc21d7a651e4acdf0c580..373dfe726c5ec4f3011f77e08d3e0850ffecf5ed 100644
+--- a/src/main/java/org/bukkit/craftbukkit/util/CraftNBTTagConfigSerializer.java
++++ b/src/main/java/org/bukkit/craftbukkit/util/CraftNBTTagConfigSerializer.java
+@@ -19,7 +19,7 @@ import net.minecraft.server.NBTTagString;
+ public class CraftNBTTagConfigSerializer {
+
+ private static final Pattern ARRAY = Pattern.compile("^\\[.*]");
+- private static final Pattern INTEGER = Pattern.compile("[-+]?(?:0|[1-9][0-9]*)?i", Pattern.CASE_INSENSITIVE);
++ private static final Pattern INTEGER = Pattern.compile("[-+]?(?:0|[1-9][0-9]*)i", Pattern.CASE_INSENSITIVE); // Paper - fix regex
+ private static final Pattern DOUBLE = Pattern.compile("[-+]?(?:[0-9]+[.]?|[0-9]*[.][0-9]+)(?:e[-+]?[0-9]+)?d", Pattern.CASE_INSENSITIVE);
+ private static final MojangsonParser MOJANGSON_PARSER = new MojangsonParser(new StringReader(""));
+