Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using the /carpet setDefault command, the input rule value is written to the conf file before being validated #2004

Open
Fallen-Breath opened this issue Oct 15, 2024 · 0 comments

Comments

@Fallen-Breath
Copy link
Contributor

carpet.api.settings.SettingsManager#setDefault

// stores different defaults in the file
private int setDefault(CommandSourceStack source, CarpetRule<?> rule, String stringValue)
{
if (locked()) return 0;
if (!rules.containsKey(rule.name())) return 0;
ConfigReadResult conf = readSettingsFromConf(getFile());
conf.ruleMap().put(rule.name(), stringValue);
writeSettingsToConf(conf); // this may feels weird, but if conf
// is locked, it will never reach this point.
try {
rule.set(source, stringValue);
Messenger.m(source ,"gi "+String.format(tr(TranslationKeys.DEFAULT_SET), RuleHelper.translatedName(rule), stringValue));
} catch (InvalidRuleValueException e) {
e.notifySource(rule.name(), source);
}
return 1;
}

As described in the title, the conf file writing (line 699) code happens before the rule value validation (line 702). As a result, invalid rule might be written to the config file, causing unexpected issues on next world loading

This issues affects all existing fabric-carpet versions. It was probrably introduced from the carpetmod 1.12 age

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant