Skip to content

Commit

Permalink
(Patch for Spigot/Paper YAML Update) Set YAML CodePoint limit to max
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Oct 2, 2022
1 parent 81b17b7 commit 3bf461d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ public static ParseableTag parseTextToTag(String arg, TagContext context) {
}

public static ParseableTag parseTextToTagInternal(String arg, TagContext context) {
if (CoreConfiguration.debugVerbose) {
Debug.echoError("(Verbose) Parse text to tag: " + arg);
}
List<ParseableTagPiece> pieces = new ArrayList<>(1);
if (arg.indexOf('>') == -1 || arg.length() < 3) {
ParseableTagPiece txt = new ParseableTagPiece();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.denizenscript.denizencore.utilities.debugging.DebugInternals;
import com.denizenscript.denizencore.utilities.text.StringHolder;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.SafeConstructor;
import org.yaml.snakeyaml.representer.Representer;
Expand All @@ -29,11 +30,22 @@ protected void addImplicitResolvers() {
}
}

private static boolean hasModernYaml = true;

public static Yaml createBaseYaml(boolean useCustomResolver) {
DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
options.setAllowUnicode(true);
return new Yaml(new SafeConstructor(), new Representer(), options, useCustomResolver ? new CustomResolver() : new Resolver());
LoaderOptions loaderOptions = new LoaderOptions();
try {
if (hasModernYaml) {
loaderOptions.setCodePointLimit(Integer.MAX_VALUE);
}
}
catch (NoSuchMethodError ignored) {
hasModernYaml = false; // pre-1.32 snakeyaml
}
return new Yaml(new SafeConstructor(), new Representer(), options, loaderOptions, useCustomResolver ? new CustomResolver() : new Resolver());
}

public static YamlConfiguration load(String data) {
Expand Down

0 comments on commit 3bf461d

Please sign in to comment.