mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
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.
This commit is contained in:
parent
6eda368428
commit
aa4b4d37dc
1 changed files with 27 additions and 0 deletions
|
@ -0,0 +1,27 @@
|
||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: mbax <matt@phozop.net>
|
||||||
|
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftNBTTagConfigSerializer.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftNBTTagConfigSerializer.java
|
||||||
|
@@ -0,0 +0,0 @@ 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(""));
|
||||||
|
|
Loading…
Reference in a new issue