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

Add more validation when setting AppOptions (PR 18413 follow-up) #18450

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions web/app_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,29 +511,30 @@ class AppOptions {
}

static set(name, value) {
const defaultOption = defaultOptions[name];

if (!defaultOption || typeof value !== typeof defaultOption.value) {
return;
}
userOptions[name] = value;
}

static setAll(options, prefs = false) {
let events;

for (const name in options) {
const userOption = options[name];
const defaultOption = defaultOptions[name],
userOption = options[name];

if (!defaultOption || typeof userOption !== typeof defaultOption.value) {
continue;
}
if (prefs) {
const defaultOption = defaultOptions[name];

if (!defaultOption) {
continue;
}
const { kind, value } = defaultOption;
const { kind } = defaultOption;

if (!(kind & OptionKind.BROWSER || kind & OptionKind.PREFERENCE)) {
continue;
}
if (typeof userOption !== typeof value) {
continue;
}
if (this.eventBus && kind & OptionKind.EVENT_DISPATCH) {
(events ||= new Map()).set(name, userOption);
}
Expand Down