Skip to content

Commit

Permalink
Review feedback: Inline then-clauses; use otherwise; return early on …
Browse files Browse the repository at this point in the history
…failure.
  • Loading branch information
otherdaniel committed Apr 16, 2024
1 parent 32de16a commit aa17bdc
Showing 1 changed file with 31 additions and 37 deletions.
68 changes: 31 additions & 37 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -272,30 +272,29 @@ For the main <dfn>sanitize</dfn> operation, using a {{ParentNode}} |node|, a
parser for which this assertion should hold. If in the future
this algorithm will be used in different contexts, this assumption
needs to be re-examined.
1. If |child| [=implements=] {{Text}}:
1. Then [=continue=].
1. else if |child| [=implements=] {{Comment}}:
1. If |config|'s {{SanitizerConfig/comments}} is not true:
1. Then [=/remove=] |child|.
1. else:
1. If |child| [=implements=] {{Text}}, then [=continue=].
1. Otherwise, if |child| [=implements=] {{Comment}}:
1. If |config|'s {{SanitizerConfig/comments}} is not true,
then [=/remove=] |child|.
1. Otherwise:
1. Let |elementName| be a {{SanitizerElementNamespace}} with |child|'s
[=Element/local name=] and [=Element/namespace=].
1. If |config|["{{SanitizerConfig/elements}}"] exists and
|config|["{{SanitizerConfig/elements}}"] does not [=SanitizerConfig/contain=]
[|elementName|]:
1. Then [=/remove=] |child|.
1. else if |config|["{{SanitizerConfig/removeElements}}"] exists and
[|elementName|], then [=/remove=] |child|.
1. Otherwise, if |config|["{{SanitizerConfig/removeElements}}"] exists and
|config|["{{SanitizerConfig/removeElements}}"] [=SanitizerConfig/contains=]
[|elementName|]:
1. Then [=/remove=] |child|.
1. If |config|["{{SanitizerConfig/replaceWithChildrenElements}}"] exists and |config|["{{SanitizerConfig/replaceWithChildrenElements}}"] [=SanitizerConfig/contains=] |elementName|:
[|elementName|], then [=/remove=] |child|.
1. If |config|["{{SanitizerConfig/replaceWithChildrenElements}}"] exists
and |config|["{{SanitizerConfig/replaceWithChildrenElements}}"]
[=SanitizerConfig/contains=] |elementName|:
1. Call [=sanitize=] on |child| with |config|.
1. Call [=replace all=] with |child|'s [=tree/children=] within |child|.
1. If |elementName| [=equals=] &laquo;[ "`name`" &rightarrow; "`template`",
"`namespace`" &rightarrow; [=HTML namespace=] ]&raquo;
1. Then call [=sanitize=] on |child|'s [=template contents=] with |config|.
1. If |child| is a [=shadow host=]:
1. Then call [=sanitize=] on |child|'s [=Element/shadow root=] with |config|.
"`namespace`" &rightarrow; [=HTML namespace=] ]&raquo,
then call [=sanitize=] on |child|'s [=template contents=] with |config|.
1. If |child| is a [=shadow host=],
then call [=sanitize=] on |child|'s [=Element/shadow root=] with |config|.
1. [=list/iterate|For each=] |attr| in |current|'s [=Element/attribute list=]:
1. Let |attrName| be a {{SanitizerAttributeNamespace}} with |attr|'s
[=Attr/local name=] and [=Attr/namespace=].
Expand All @@ -304,42 +303,38 @@ For the main <dfn>sanitize</dfn> operation, using a {{ParentNode}} |node|, a
|attrName|:
1. If "data-" is a [=code unit prefix=] of [=Attr/local name=] and
if [=Attr/namespace=] is `null` and
if |config|["{{SanitizerConfig/dataAttributes}}"] exists and is false:
1. Then [=remove an attribute|remove=] |attr||.
1. else if |config|["{{SanitizerConfig/removeAttributes}}"] exists and
if |config|["{{SanitizerConfig/dataAttributes}}"] exists and is false,
then [=remove an attribute|remove=] |attr|.
1. Otherwise, if |config|["{{SanitizerConfig/removeAttributes}}"] exists and
|config|["{{SanitizerConfig/removeAttributes}}"] [=SanitizerConfig/contains=]
|attrName|:
1. Then [=remove an attribute|remove=] |attr|.
|attrName|, then [=remove an attribute|remove=] |attr|.
1. If |config|["{{SanitizerConfig/elements}}"][|elementName|] exists,
and if
|config|["{{SanitizerConfig/elements}}"][|elementName|]["{{SanitizerElementNamespaceWithAttributes/attributes}}"]
exists, and if
|config|["{{SanitizerConfig/elements}}"][|elementName|]["{{SanitizerElementNamespaceWithAttributes/attributes}}"]
does not [=SanitizerConfig/contain=] |attrName|:
1. Then [=remove an attribute|remove=] |attr|.
does not [=SanitizerConfig/contain=] |attrName|,
then [=remove an attribute|remove=] |attr|.
1. If |config|["{{SanitizerConfig/elements}}"][|elementName|] exists,
and if
|config|["{{SanitizerConfig/elements}}"][|elementName|]["{{SanitizerElementNamespaceWithAttributes/removeAttributes}}"]
exists, and if
|config|["{{SanitizerConfig/elements}}"][|elementName|]["{{SanitizerElementNamespaceWithAttributes/removeAttributes}}"]
[=SanitizerConfig/contains=] |attrName|:
1. Then [=remove an attribute|remove=] |attr|.
[=SanitizerConfig/contains=] |attrName|,
then [=remove an attribute|remove=] |attr|.
1. If the [=navigating URL attributes list=] [=SanitizerConfig/contains=]
&laquo;[|elementName|, |attrName|]&raquo; and |attr|
[=contains a javascript: URL=]:
1. Then [=remove an attribute|remove=] |attr|.
[=contains a javascript: URL=],
then [=remove an attribute|remove=] |attr|.
1. If |child|'s [=Element/namespace=] [=string/is=] the
[=MathML Namespace=] and |attr|'s [=Attr/local name=] [=string/is=]
"`href`" and |attr| [=contains a javascript: URL=]:
1. Then [=remove an attribute|remove=] |attr|.
"`href`" and |attr| [=contains a javascript: URL=],
then [=remove an attribute|remove=] |attr|.
1. If the [=animating URL attributes list=] [=SanitizerConfig/contains=]
&laquo;[|elementName|, |attrName|]&raquo; and |attr|'s
[=get an attribute value|value=] [=string/is=] "`href`" or
"`xlink:href`":
1. Then [=remove an attribute|remove=] |attr|.
"`xlink:href`", then [=remove an attribute|remove=] |attr|.
1. Call [=sanitize=] on |child|'s [=Element/shadow root=] with |config|.
1. else:
1. [=/Remove=] |child|.

</div>

Expand Down Expand Up @@ -368,9 +363,8 @@ To determine whether an |attribute| <dfn>contains a javascript: URL</dfn>, do th
1. Let |url| be the result of running the [=basic URL parser=]
on |attribute|'s [=get an attribute value|value=].
1. Let |contains javascript: url| be:
|url| is not `failure` and |url|'s [=url/scheme=] [=string/is=] "`javascript`".
1. Return |contains javascript: url|.
1. If |url| is `failure` return false.
1. Return whether |url|'s [=url/scheme=] [=string/is=] "`javascript`".
</div>
Expand Down Expand Up @@ -615,7 +609,7 @@ Note: The initial set of [=assert=]s assert properties of the built-in
|config|["{{SanitizerConfig/removeAttributes}}"] [=map/exist=]:
1. Set |result|["{{SanitizerConfig/attributes}}"] to
|default|["{{SanitizerConfig/attributes}}"].
1. Else (if not |safe|):
1. Otherwise (if not |safe|):
1. If neither |config|["{{SanitizerConfig/elements}}"] nor
|config|["{{SanitizerConfig/removeElements}}"] [=map/exist=]:
1. Set |result|["{{SanitizerConfig/elements}}"] to
Expand Down

0 comments on commit aa17bdc

Please sign in to comment.