9
9
* Possible property values
10
10
* @typedef {string|number|boolean } PrimitivePropertyValue
11
11
* Possible primitive HTML attribute values
12
- * @typedef {string|[string, ...Array<PrimitivePropertyValue>] } AttributeValue
13
- * @typedef {Record<string, Array<PrimitivePropertyValue>> } AttributeMap
12
+ * @typedef {string|[string, ...Array<PrimitivePropertyValue|RegExp >] } AttributeValue
13
+ * @typedef {Record<string, Array<PrimitivePropertyValue|RegExp >> } AttributeMap
14
14
*
15
15
* @typedef Schema Sanitization configuration
16
16
* @property {Record<string, Array<AttributeValue>> } [attributes]
@@ -236,7 +236,7 @@ function handleProperties(schema, properties, node, stack) {
236
236
for ( key in props ) {
237
237
if ( own . call ( props , key ) ) {
238
238
let value = props [ key ]
239
- /** @type {Array<PrimitivePropertyValue> } */
239
+ /** @type {Array<PrimitivePropertyValue|RegExp > } */
240
240
let definition
241
241
242
242
if ( own . call ( allowed , key ) ) {
@@ -281,9 +281,10 @@ function handleDoctypeName() {
281
281
/**
282
282
* Sanitize `tagName`.
283
283
*
284
- * @type { Handler }
285
- * @param {unknown } tagName
284
+ * @param { Schema } schema
285
+ * @param {string } tagName
286
286
* @param {Node } _
287
+ * @param {Array<string> } stack
287
288
* @returns {string|false }
288
289
*/
289
290
function handleTagName ( schema , tagName , _ , stack ) {
@@ -354,7 +355,7 @@ function allow(_, value) {
354
355
* @param {Schema } schema
355
356
* @param {Array<unknown> } values
356
357
* @param {string } prop
357
- * @param {Array<PrimitivePropertyValue> } definition
358
+ * @param {Array<PrimitivePropertyValue|RegExp > } definition
358
359
* @returns {Array<string|number> }
359
360
*/
360
361
function handlePropertyValues ( schema , values , prop , definition ) {
@@ -380,7 +381,7 @@ function handlePropertyValues(schema, values, prop, definition) {
380
381
* @param {Schema } schema
381
382
* @param {unknown } value
382
383
* @param {string } prop
383
- * @param {Array<PropertyValue> } definition
384
+ * @param {Array<PropertyValue|RegExp > } definition
384
385
* @returns {PropertyValue }
385
386
*/
386
387
function handlePropertyValue ( schema , value , prop , definition ) {
@@ -389,7 +390,12 @@ function handlePropertyValue(schema, value, prop, definition) {
389
390
typeof value === 'number' ||
390
391
typeof value === 'string' ) &&
391
392
safeProtocol ( schema , value , prop ) &&
392
- ( definition . length === 0 || definition . includes ( value ) )
393
+ ( definition . length === 0 ||
394
+ definition . some ( ( allowed ) =>
395
+ allowed && typeof allowed === 'object' && 'flags' in allowed
396
+ ? allowed . test ( String ( value ) )
397
+ : allowed === value
398
+ ) )
393
399
) {
394
400
return schema . clobberPrefix &&
395
401
schema . clobber &&
0 commit comments