Skip to content

Commit 282360c

Browse files
committed
Assert that the config is valid
1 parent 84178c2 commit 282360c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

index.bs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ By explicitly sorting the result of this method, we give implementations the opp
312312
</div>
313313

314314
1. Let |config| be [=this=]'s [=Sanitizer/configuration=].
315+
1. [=Assert=]: |config| is [=SanitizerConfig/valid=].
315316
1. If |config|["{{SanitizerConfig/elements}}"] [=map/exists=]:
316317
1. [=list/iterate|For any=] |element| of |config|["{{SanitizerConfig/elements}}"]:
317318
1. If |element|["{{SanitizerElementNamespaceWithAttributes/attributes}}"] [=map/exists=]:
@@ -351,6 +352,7 @@ allow- or remove-lists for attributes. This requires that we distinguish 4 cases
351352
</div>
352353

353354
1. Let |configuration| be [=this=]'s [=Sanitizer/configuration=].
355+
1. [=Assert=]: |configuration| is [=SanitizerConfig/valid=].
354356
1. Set |element| to the result of [=canonicalize a sanitizer element with attributes=] with
355357
|element|.
356358
1. If |configuration|["{{SanitizerConfig/elements}}"] [=map/exists=]:
@@ -437,6 +439,7 @@ to [=remove an element=] with |element| and [=this=]'s [=Sanitizer/configuration
437439
The <dfn for="Sanitizer" method export>replaceElementWithChildren(|element|)</dfn> method steps are:
438440

439441
1. Let |configuration| be [=this=]'s [=Sanitizer/configuration=].
442+
1. [=Assert=]: |configuration| is [=SanitizerConfig/valid=].
440443
1. Set |element| to the result of [=canonicalize a sanitizer element=] with |element|.
441444
1. If |configuration|["{{SanitizerConfig/replaceWithChildrenElements}}"] [=map/contains=] |element|:
442445
1. Return false.
@@ -457,6 +460,7 @@ up per-element allow- or remove-lists to maintain our validity criteria.
457460
</div>
458461

459462
1. Let |configuration| be [=this=]'s [=Sanitizer/configuration=].
463+
1. [=Assert=]: |configuration| is [=SanitizerConfig/valid=].
460464
1. Set |attribute| to the result of [=canonicalize a sanitizer attribute=] with |attribute|.
461465
1. If |configuration|["{{SanitizerConfig/attributes}}"] [=map/exists=]:
462466
1. [=Comment=]: If we have a global allow-list, we need to add |attribute|.
@@ -495,6 +499,7 @@ The <dfn for="Sanitizer" method export>removeAttribute(|attribute|)</dfn> method
495499
The <dfn for="Sanitizer" method export>setComments(|allow|)</dfn> method steps are:
496500

497501
1. Let |configuration| be [=this=]'s [=Sanitizer/configuration=].
502+
1. [=Assert=]: |configuration| is [=SanitizerConfig/valid=].
498503
1. If |configuration|["{{SanitizerConfig/comments}}"] [=map/exists=] and
499504
|configuration|["{{SanitizerConfig/comments}}"] equals |allow|, then return false;
500505
1. Set |configuration|["{{SanitizerConfig/comments}}"] to |allow|.
@@ -506,6 +511,7 @@ The <dfn for="Sanitizer" method export>setComments(|allow|)</dfn> method steps a
506511
The <dfn for="Sanitizer" method export>setDataAttributes(|allow|)</dfn> method steps are:
507512

508513
1. Let |configuration| be [=this=]'s [=Sanitizer/configuration=].
514+
1. [=Assert=]: |configuration| is [=SanitizerConfig/valid=].
509515
1. If |configuration|["{{SanitizerConfig/attributes}}"] does not [=map/exist=], then return false.
510516
1. If |configuration|["{{SanitizerConfig/dataAttributes}}"] equals |allow|, then return false.
511517
1. If |allow| is true:
@@ -835,6 +841,7 @@ For the main <dfn>sanitize</dfn> operation, using a {{ParentNode}} |node|, a
835841
{{Sanitizer}} |sanitizer|, and a [=boolean=] |safe|, run these steps:
836842

837843
1. Let |configuration| be the value of |sanitizer|'s [=Sanitizer/configuration=].
844+
1. [=Assert=]: |configuration| is [=SanitizerConfig/valid=].
838845
1. If |safe| is true, then set |configuration| to the result of calling [=remove unsafe=] on |configuration|.
839846
1. Call [=sanitize core=] on |node|, |configuration|, and with [=handleJavascriptNavigationUrls=] set to |safe|.
840847

@@ -1000,6 +1007,7 @@ This method requires that we distinguish 4 cases:
10001007
10011008
</div>
10021009
1010+
1. [=Assert=]: |configuration| is [=SanitizerConfig/valid=].
10031011
1. Set |element| to the result of [=canonicalize a sanitizer element=] with |element|.
10041012
1. Set |modified| to the result of
10051013
[=SanitizerConfig/remove=] |element| from
@@ -1031,6 +1039,7 @@ remove-list. If we add |attribute| to the global remove-list, we may need to do
10311039
to fix up per-element allow- or remove-lists to maintain our validity criteria. If we remove
10321040
|attribute| from a global allow-list, we may also have to remove it from local remove-lists.
10331041
1042+
1. [=Assert=]: |configuration| is [=SanitizerConfig/valid=].
10341043
1. Set |attribute| to the result of [=canonicalize a sanitizer attribute=] with |attribute|.
10351044
1. If |configuration|["{{SanitizerConfig/attributes}}"] [=map/exists=]:
10361045
1. [=Comment=]: If we have a global allow-list, we need to add |attribute|.
@@ -1078,6 +1087,7 @@ Note: While this algorithm is called [=remove unsafe=], we use
10781087
1. [=Assert=]: The [=map/get the keys|key set=] of [=built-in safe baseline configuration=]
10791088
[=set/equals=]
10801089
&laquo;[ "{{SanitizerConfig/removeElements}}", "{{SanitizerConfig/removeAttributes}}" ] &raquo;.
1090+
1. [=Assert=]: |configuration| is [=SanitizerConfig/valid=].
10811091
1. Let |result| be false.
10821092
1. [=list/For each=] |element| in
10831093
[=built-in safe baseline configuration=][{{SanitizerConfig/removeElements}}]:

0 commit comments

Comments
 (0)