🤖 Merge PR #45796 [sanitize-html] fix IOptions["allowedClasses"] type by @JoelWee

The source code does not support setting boolean to allowedClasses. It only supports this for individual tags in allowedClasses. E.g. { p: false } will allow all classes for the p tag.
This commit is contained in:
JoelWee 2020-06-30 18:10:11 +01:00 committed by GitHub
parent 5e72001c2a
commit 607b7f1b4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -57,7 +57,7 @@ declare namespace sanitize {
interface IOptions {
allowedAttributes?: { [index: string]: AllowedAttribute[] } | boolean;
allowedStyles?: { [index: string]: { [index: string]: RegExp[] } };
allowedClasses?: { [index: string]: string[] } | boolean;
allowedClasses?: { [index: string]: string[] | boolean };
allowedIframeHostnames?: string[];
allowIframeRelativeUrls?: boolean;
allowedSchemes?: string[] | boolean;

View File

@ -6,6 +6,10 @@ let options: sanitize.IOptions = {
'a': sanitize.defaults.allowedAttributes['a'].concat('rel'),
'img': ['src', 'height', 'width', 'alt', 'style']
},
allowedClasses: {
a: ['className'],
p: false,
},
allowedStyles: {
'*': {
color: [/^red$/],