From 42799043b2f9629401af64339eafac812abe559e Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Mon, 29 Jun 2020 09:06:29 +1000 Subject: [PATCH] SPIGOT-5881: SnakeYaml 1.26 limits non-scalar (null) nodes while 1.25 does not By: md_5 --- .../org/bukkit/configuration/file/YamlConfiguration.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/paper-api/src/main/java/org/bukkit/configuration/file/YamlConfiguration.java b/paper-api/src/main/java/org/bukkit/configuration/file/YamlConfiguration.java index dc8cb19371..be8d35f156 100644 --- a/paper-api/src/main/java/org/bukkit/configuration/file/YamlConfiguration.java +++ b/paper-api/src/main/java/org/bukkit/configuration/file/YamlConfiguration.java @@ -13,6 +13,7 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.InvalidConfigurationException; import org.jetbrains.annotations.NotNull; import org.yaml.snakeyaml.DumperOptions; +import org.yaml.snakeyaml.LoaderOptions; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.error.YAMLException; import org.yaml.snakeyaml.representer.Representer; @@ -25,8 +26,9 @@ public class YamlConfiguration extends FileConfiguration { protected static final String COMMENT_PREFIX = "# "; protected static final String BLANK_CONFIG = "{}\n"; private final DumperOptions yamlOptions = new DumperOptions(); + private final LoaderOptions loaderOptions = new LoaderOptions(); private final Representer yamlRepresenter = new YamlRepresenter(); - private final Yaml yaml = new Yaml(new YamlConstructor(), yamlRepresenter, yamlOptions); + private final Yaml yaml = new Yaml(new YamlConstructor(), yamlRepresenter, yamlOptions, loaderOptions); @NotNull @Override @@ -51,6 +53,7 @@ public class YamlConfiguration extends FileConfiguration { Map input; try { + loaderOptions.setMaxAliasesForCollections(Integer.MAX_VALUE); // SPIGOT-5881: Not ideal, but was default pre SnakeYAML 1.26 input = (Map) yaml.load(contents); } catch (YAMLException e) { throw new InvalidConfigurationException(e);