Skip to content

Commit

Permalink
[preferences] Reject invalid preference schemas.
Browse files Browse the repository at this point in the history
Fixes #6106

Signed-off-by: Alex Tugarev <alex.tugarev@typefox.io>
  • Loading branch information
AlexTugarev committed Sep 5, 2019
1 parent 78e0b20 commit 62328bf
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ export class PreferenceSchemaProvider extends PreferenceProvider {
}

protected doSetSchema(schema: PreferenceSchema): PreferenceProviderDataChange[] {
const ajv = new Ajv();
const valid = ajv.validateSchema(schema);
if (!valid) {
const errors = !!ajv.errors ? ajv.errorsText(ajv.errors) : 'unknown validation error';
console.error('An invalid preference schema was rejected: ' + errors);
return [];
}
const scope = PreferenceScope.Default;
const domain = this.getDomain();
const changes: PreferenceProviderDataChange[] = [];
Expand Down

0 comments on commit 62328bf

Please sign in to comment.