Update Upstream

0ef38b5 Use SnakeYaml 1.32+, set loader code point limit. (2194)

Defaults to 64MB, can be set via -Dworldedit.yaml.codePointLimit sysprop.
This commit is contained in:
Alexander Brandes 2022-09-26 23:45:06 +02:00
parent 10b852d416
commit 87f680683d
No known key found for this signature in database
GPG Key ID: 158F5701A6AAD00C
2 changed files with 15 additions and 5 deletions

View File

@ -12,7 +12,7 @@ applyPlatformAndCoreConfiguration()
dependencies { dependencies {
constraints { constraints {
implementation("org.yaml:snakeyaml") { implementation("org.yaml:snakeyaml") {
version { strictly("1.30") } version { strictly("1.33") }
because("Bukkit provides SnakeYaml") because("Bukkit provides SnakeYaml")
} }
} }

View File

@ -21,6 +21,7 @@ package com.sk89q.util.yaml;
import com.sk89q.util.StringUtil; import com.sk89q.util.StringUtil;
import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.SafeConstructor; import org.yaml.snakeyaml.constructor.SafeConstructor;
import org.yaml.snakeyaml.nodes.Tag; import org.yaml.snakeyaml.nodes.Tag;
@ -89,13 +90,22 @@ public class YAMLProcessor extends YAMLNode {
super(new LinkedHashMap<>(), writeDefaults); super(new LinkedHashMap<>(), writeDefaults);
this.format = format; this.format = format;
DumperOptions options = new DumperOptions(); DumperOptions dumperOptions = new DumperOptions();
options.setIndent(4); dumperOptions.setIndent(4);
options.setDefaultFlowStyle(format.getStyle()); dumperOptions.setDefaultFlowStyle(format.getStyle());
Representer representer = new FancyRepresenter(); Representer representer = new FancyRepresenter();
representer.setDefaultFlowStyle(format.getStyle()); representer.setDefaultFlowStyle(format.getStyle());
yaml = new Yaml(new SafeConstructor(), representer, options); LoaderOptions loaderOptions = new LoaderOptions();
try {
// 64 MB default
int yamlCodePointLimit = Integer.getInteger("worldedit.yaml.codePointLimit", 64 * 1024 * 1024);
loaderOptions.setCodePointLimit(yamlCodePointLimit);
} catch (NoSuchMethodError ignored) {
// pre-1.32 snakeyaml
}
yaml = new Yaml(new SafeConstructor(), representer, dumperOptions, loaderOptions);
this.file = file; this.file = file;
} }