Skip to content

Commit

Permalink
Merge pull request #18450 from Snuffleupagus/AppOptions-set-validation
Browse files Browse the repository at this point in the history
Add more validation when setting `AppOptions` (PR 18413 follow-up)
  • Loading branch information
timvandermeij authored Jul 20, 2024
2 parents 7a8acee + 216d3a9 commit e92a6a1
Showing 1 changed file with 11 additions and 10 deletions.
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

0 comments on commit e92a6a1

Please sign in to comment.