Skip to content

Commit 3143eda

Browse files
committed
Lower case sanitizer in Default sanitizer configuration
1 parent e26c1b8 commit 3143eda

File tree

11 files changed

+28
-26
lines changed

11 files changed

+28
-26
lines changed

files/en-us/web/api/document/parsehtml_static/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Document.parseHTML(input, options)
2626
- `options` {{optional_inline}}
2727
- : An options object with the following optional parameters:
2828
- `sanitizer`
29-
- : A {{domxref("Sanitizer")}} or {{domxref("SanitizerConfig")}} object which defines what elements of the input will be allowed or removed, or the string `"default"` for the [default `Sanitizer` configuration](/en-US/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration).
29+
- : A {{domxref("Sanitizer")}} or {{domxref("SanitizerConfig")}} object which defines what elements of the input will be allowed or removed, or the string `"default"` for the [default sanitizer configuration](/en-US/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration).
3030
The method will remove any XSS-unsafe elements and attributes, even if allowed by the sanitizer.
3131
If not specified, the default `Sanitizer` configuration is used.
3232

@@ -50,7 +50,7 @@ A {{domxref("Document")}}.
5050
The **`parseHTML()`** method parses and sanitize a string of HTML in order to create a new {{domxref("Document")}} instance that is XSS-safe.
5151
The resulting `Document` will have a [content type](/en-US/docs/Web/API/Document/contentType) of "text/html", a [character set](/en-US/docs/Web/API/Document/characterSet) of UTF-8, and a URL of "about:blank".
5252

53-
If no sanitizer is specified in the `options.sanitizer` parameter, `parseHTML()` is used with the [default `Sanitizer` configuration](/en-US/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration).
53+
If no sanitizer is specified in the `options.sanitizer` parameter, `parseHTML()` is used with the [default sanitizer configuration](/en-US/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration).
5454
This configuration is suitable for the majority of use cases as it prevents XSS attacks, as well as other attacks like clickjacking or spoofing.
5555

5656
A custom `Sanitizer` or `SanitizerConfig` can be specified to choose which elements, attributes, and comments are allowed or removed.

files/en-us/web/api/document/parsehtmlunsafe_static/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Document.parseHTMLUnsafe(input, options)
3535
- : An options object with the following optional parameters:
3636
- `sanitizer` {{optional_inline}}
3737
- : A {{domxref("Sanitizer")}} or {{domxref("SanitizerConfig")}} object which defines what elements of the input will be allowed or removed.
38-
This can also be a string with the value `"default"`, which applies a `Sanitizer` with the (XSS-safe) [default `Sanitizer` configuration](/en-US/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration).
38+
This can also be a string with the value `"default"`, which applies a `Sanitizer` with the (XSS-safe) [default sanitizer configuration](/en-US/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration).
3939
If not specified, no sanitizer is used.
4040

4141
Note that generally a `Sanitizer` is expected than the to be more efficient than a `SanitizerConfig` if the configuration is to reused.
@@ -78,7 +78,7 @@ This ensures that the input is passed through a transformation function, which h
7878
Using `TrustedHTML` makes it possible to audit and check that sanitization code is effective in just a few places, rather than scattered across all your injection sinks.
7979
You should not need to pass a sanitizer to the method when using `TrustedHTML`.
8080

81-
If for any reason you can't use `TrustedHTML` (or even better, `setHTML()`) then the next safest option is to use `setHTMLUnsafe()` with the XSS-safe [default `Sanitizer` configuration](/en-US/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration).
81+
If for any reason you can't use `TrustedHTML` (or even better, `setHTML()`) then the next safest option is to use `setHTMLUnsafe()` with the XSS-safe [default sanitizer configuration](/en-US/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration).
8282

8383
## Specifications
8484

files/en-us/web/api/element/sethtml/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ setHTML(input, options)
3131
- `sanitizer`
3232
- : A {{domxref("Sanitizer")}} or {{domxref("SanitizerConfig")}} object which defines what elements of the input will be allowed or removed, or the string `"default"` for the default configuration.
3333
The method will remove any XSS-unsafe elements and attributes, even if allowed by the sanitizer.
34-
If not specified, the [default `Sanitizer` configuration](/en-US/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration) is used.
34+
If not specified, the [default sanitizer configuration](/en-US/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration) is used.
3535

3636
Note that if you're using the same configuration multiple times, it's expected to be more efficient to use a `Santitizer` and modify it when you need to.
3737

@@ -55,7 +55,7 @@ The **`setHTML()`** method provides an XSS-safe method to parse and sanitize a s
5555
`setHTML()` drops any elements in the HTML input string that are invalid in the context of the current element, such as a {{htmlelement("col")}} element outside of a {{htmlelement("table")}}.
5656
It then removes any HTML entities that aren't allowed by the sanitizer configuration, and further removes any XSS-unsafe elements or attributes — whether or not they are allowed by the sanitizer.
5757

58-
If no sanitizer is specified in the `options.sanitizer` parameter, `setHTML()` is used with the [default `Sanitizer` configuration](/en-US/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration).
58+
If no sanitizer is specified in the `options.sanitizer` parameter, `setHTML()` is used with the [default sanitizer configuration](/en-US/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration).
5959
This configuration is suitable for the majority of use cases as it prevents XSS attacks, as well as other attacks like clickjacking or spoofing.
6060

6161
A custom `Sanitizer` or `SanitizerConfig` can be specified to choose which elements, attributes, and comments are allowed or removed.

files/en-us/web/api/element/sethtmlunsafe/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ setHTMLUnsafe(input, options)
3535
- : An options object with the following optional parameters:
3636
- `sanitizer` {{optional_inline}}
3737
- : A {{domxref("Sanitizer")}} or {{domxref("SanitizerConfig")}} object that defines what elements of the input will be allowed or removed.
38-
This can also be a string with the value `"default"`, which applies a `Sanitizer` with the (XSS-safe) [default `Sanitizer` configuration](/en-US/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration).
38+
This can also be a string with the value `"default"`, which applies a `Sanitizer` with the (XSS-safe) [default sanitizer configuration](/en-US/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration).
3939
If not specified, no sanitizer is used.
4040

4141
Note that if you're using the same configuration multiple times, it's expected to be more efficient to use a `Santitizer` and modify it when you need to.
@@ -79,7 +79,7 @@ This ensures that the input is passed through a transformation function, which h
7979
Using `TrustedHTML` makes it possible to audit and check that sanitization code is effective in just a few places, rather than scattered across all your injection sinks.
8080
You should not have to pass a sanitizer to the method when using `TrustedHTML`.
8181

82-
If for any reason you can't use `TrustedHTML` (or even better, `setHTML()`) then the next safest option is to use `setHTMLUnsafe()` with the [default `Sanitizer` configuration](/en-US/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration).
82+
If for any reason you can't use `TrustedHTML` (or even better, `setHTML()`) then the next safest option is to use `setHTMLUnsafe()` with the [default sanitizer configuration](/en-US/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration).
8383

8484
### When should `setHTMLUnsafe()` be used?
8585

files/en-us/web/api/html_sanitizer_api/default_sanitizer_configuration/index.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
2-
title: Default Sanitizer configuration
2+
title: Default sanitizer configuration
33
slug: Web/API/HTML_Sanitizer_API/Default_sanitizer_configuration
44
page-type: guide
55
---
66

77
{{DefaultAPISidebar("HTML Sanitizer API")}}
88

9-
The default sanitizer configuration defines the {{domxref("Sanitizer")}} that is used by default if you call the [safe sanitization methods](/en-US/docs/Web/API/HTML_Sanitizer_API#sanitization_methods), such as {{domxref("Element.setHTML()")}}, {{domxref("ShadowRoot.setHTML()")}}, and {{domxref("Document.parseHTML_static","Document.parseHTML()")}}, without specifying a custom sanitizer.
10-
It is also the default configuration returned by the [`Sanitizer()` constructor](/en-US/docs/Web/API/Sanitizer/Sanitizer) if no `configuration` is passed as an argument.
9+
The default sanitizer configuration defines the configuration returned by the [`Sanitizer()` constructor](/en-US/docs/Web/API/Sanitizer/Sanitizer) if no `configuration` is passed as an argument.
10+
This same configuration is implicitly used if you call the [safe sanitization methods](/en-US/docs/Web/API/HTML_Sanitizer_API#sanitization_methods), such as {{domxref("Element.setHTML()")}}, {{domxref("ShadowRoot.setHTML()")}}, and {{domxref("Document.parseHTML_static","Document.parseHTML()")}}, without specifying a custom sanitizer.
1111

1212
This configuration removes the following sorts of items:
1313

@@ -20,9 +20,11 @@ This configuration removes the following sorts of items:
2020
It therefore provides a sanitizer with a minimal attack surface, which is still suitable for the majority of sanitization use cases.
2121

2222
> [!NOTE]
23-
> The specification calls this configuration the [built-in safe default configuration](https://wicg.github.io/sanitizer-api/#built-in-safe-default-configuration).
23+
> Calling {{domxref("Sanitizer.removeUnsafe()")}}, or passing a custom sanitizer to the safe sanitization method, only removes the XSS-unsafe items.
24+
> It does not remove the additional items, comments, and `data-*` attributes.
2425
25-
The following sections list all the elements, with a ✓ mark indicating those that are allowed by the default configuration, and also listing the attributes that are allowed only for particular elements.
26+
The following sections list all the elements, with a ✓ mark indicating those that are _allowed_ by the default configuration (the ❌ therefore indicates those that will be removed).
27+
The "Additional allowed attributes" column lists the attributes that are allowed for the corresponding elements; any other attributes on the element would be removed (unless allowed by the global attributes).
2628
The [Global attributes](#global_attributes) section lists the attributes that are allowed on all elements (the attributes that are not removed when the configuration is used).
2729

2830
## HTML elements

files/en-us/web/api/html_sanitizer_api/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The sanitizer objects defines the HTML entities that will be filtered out of the
3232
The {{domxref('Element')}} methods are context aware, and will additionally drop any elements that the HTML specification does not allow in the target element.
3333

3434
The safe methods always remove XSS-unsafe elements and attributes.
35-
If no sanitizer is passed as a parameter they will use the [default `Sanitizer` configuration](#default_sanitizer_configuration), which removes both XSS-unsafe elements and attributes, such as {{htmlelement("script")}} elements and `onclick` event handlers, along with others that might be be used in other kinds of attacks if provided as user input.
35+
If no sanitizer is passed as a parameter they will use the [default sanitizer configuration](#default_sanitizer_configuration), which removes both XSS-unsafe elements and attributes, such as {{htmlelement("script")}} elements and `onclick` event handlers, along with others that might be be used in other kinds of attacks if provided as user input.
3636
If a custom sanitizer is used with a safe method, it is implicitly updated to remove any elements and attributes that are not XSS-safe (note that the passed sanitizer is not modified, and might still allow unsafe entities if used with an unsafe method).
3737

3838
The safe methods should be used instead of {{domxref("Element.innerHTML")}}, {{domxref("Element.outerHTML")}}, or {{domxref("ShadowRoot.innerHTML")}}, for injecting untrusted HTML content.
@@ -193,9 +193,9 @@ So if you call `allowElement()` on an allow configuration and the specified elem
193193
But if the element is already present then the method would return `false`.
194194
Note that if you call the same method to set a per-element attribute, this will return `false` if called on a remove sanitizer, because the change cannot be made.
195195

196-
#### Default `Sanitizer` configuration
196+
#### Default sanitizer configuration
197197

198-
The default `Sanitizer` configuration defines the {{domxref("Sanitizer")}} that is used if you call {{domxref("Element.setHTML()")}} or the other [safe sanitization methods](/en-US/docs/Web/API/HTML_Sanitizer_API#sanitization_methods) without a custom sanitizer.
198+
The default sanitizer configuration defines the sanitizer that is used if you call {{domxref("Element.setHTML()")}} or the other [safe sanitization methods](/en-US/docs/Web/API/HTML_Sanitizer_API#sanitization_methods) without passing a sanitizer object.
199199
It is also the configuration that is returned by the [`Sanitizer()` constructor](/en-US/docs/Web/API/Sanitizer/Sanitizer) when no configuration is set.
200200

201201
This configuration removes the following sorts of items:
@@ -209,7 +209,7 @@ It therefore provides a sanitizer with a minimal attack surface, which is still
209209
Note that if you specify a _custom_ sanitizer that allows XSS-unsafe items to a safe sanitization method, these items will still be removed from the input.
210210
However, the safe sanitization methods do not automatically remove the additional items, comments, and `data-*` attributes, that would be removed by the default configuration.
211211

212-
For a listing of the allowed elements and attributes, see [Default `Sanitizer` configuration](/en-US/docs/Web/API/HTML_Sanitizer_API/Default_sanitizer_configuration).
212+
For a listing of the allowed elements and attributes, see [Default sanitizer configuration](/en-US/docs/Web/API/HTML_Sanitizer_API/Default_sanitizer_configuration).
213213

214214
### Sanitization and Trusted Types
215215

files/en-us/web/api/sanitizer/get/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ log(JSON.stringify(defaultConfig, null, 2));
140140

141141
#### Results
142142

143-
The [default `Sanitizer` configuration](/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration) is logged below.
143+
The [default sanitizer configuration](/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration) is logged below.
144144
Note that the default configuration is quite big, allowing many elements and attributes.
145145

146146
{{EmbedLiveSample("Getting the default sanitizer","100","480px")}}

files/en-us/web/api/sanitizer/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ It can be used with the following [sanitization methods](/en-US/docs/Web/API/HTM
4444
- Unsafe methods: {{domxref("Element.setHTMLUnsafe()")}}, {{domxref("ShadowRoot.setHTMLUnsafe()")}}, and [`Document.parseHTMLUnsafe()`](/en-US/docs/Web/API/Document/parseHTMLUnsafe_static).
4545

4646
A `Sanitizer` instance can be constructed from a {{domxref("SanitizerConfig")}}, and is effectively a wrapper around that object. A `Sanitizer` and a `SanitizerConfig` can be used with the same methods, but if you're using the same configuration multiple times, it's expected to be more efficient to use a `Santitizer` and modify it when you need to.
47-
If no `SanitizerConfig` is passed to the constructor, the sanitizer is created with the [default `Sanitizer` configuration](/en-US/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration), which removes XSS-unsafe elements and attributes, along with other elements and attributes that can potentially be used in other attacks, such as clickjacking and spoofing.
47+
If no `SanitizerConfig` is passed to the constructor, the sanitizer is created with the [default sanitizer configuration](/en-US/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration), which removes XSS-unsafe elements and attributes, along with other elements and attributes that can potentially be used in other attacks, such as clickjacking and spoofing.
4848

4949
Note that any `Sanitizer` can be made XSS-safe by calling {{domxref("Sanitizer.removeUnsafe()")}}, but other potentially dangerous elements and attributes — which are removed by the default configuration — may still be present.
5050

files/en-us/web/api/sanitizer/sanitizer/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ new Sanitizer(configuration)
2020
### Parameters
2121

2222
- `configuration` {{optional_inline}}
23-
- : A {{domxref("SanitizerConfig")}} defining a [valid configuration](/en-US/docs/Web/API/SanitizerConfig#valid_configuration), or the string `"default"` to indicate the [default `Sanitizer` configuration](/en-US/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration).
23+
- : A {{domxref("SanitizerConfig")}} defining a [valid configuration](/en-US/docs/Web/API/SanitizerConfig#valid_configuration), or the string `"default"` to indicate the [default sanitizer configuration](/en-US/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration).
2424
The "empty configuration" (`{}`) can also be passed, and results in a [remove configuration](/en-US/docs/Web/API/HTML_Sanitizer_API#remove_configurations) with empty arrays.
2525

2626
If omitted, the constructor returns a `Sanitizer` with the default configuration.
@@ -41,7 +41,7 @@ An instance of the {{domxref("Sanitizer")}} object.
4141

4242
The constructor creates a new {{domxref("Sanitizer")}} object, which can be used to filter unwanted elements and attributes from HTML or documents before they are inserted/parsed into the DOM.
4343

44-
The [default `Sanitizer` configuration](/en-US/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration) is an [allow sanitizer](/en-US/docs/Web/API/HTML_Sanitizer_API#allow_configurations) that omits XSS-unsafe elements and attributes, along with other elements and attributes that can potentially be used in other attacks, such as clickjacking and spoofing.
44+
The [default sanitizer configuration](/en-US/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration) is an [allow sanitizer](/en-US/docs/Web/API/HTML_Sanitizer_API#allow_configurations) that omits XSS-unsafe elements and attributes, along with other elements and attributes that can potentially be used in other attacks, such as clickjacking and spoofing.
4545
This configuration is suitable for the majority of sanitization use cases.
4646
It is created if `"default"` or no object is passed to the constructor.
4747

files/en-us/web/api/shadowroot/sethtml/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ setHTML(input, options)
3131
- `options` {{optional_inline}}
3232
- : An options object with the following optional parameters:
3333
- `sanitizer`
34-
- : A {{domxref("Sanitizer")}} or {{domxref("SanitizerConfig")}} object which defines what elements of the input will be allowed or removed, or the string `"default"` for the [default `Sanitizer` configuration](/en-US/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration).
34+
- : A {{domxref("Sanitizer")}} or {{domxref("SanitizerConfig")}} object which defines what elements of the input will be allowed or removed, or the string `"default"` for the [default sanitizer configuration](/en-US/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration).
3535
The method will remove any XSS-unsafe elements and attributes, even if allowed by the sanitizer.
3636
If not specified, the default `Sanitizer` configuration is used.
3737

@@ -56,7 +56,7 @@ The **`setHTML()`** method provides an XSS-safe method to parse and sanitize a s
5656

5757
`setHTML()` removes any HTML entities that aren't allowed by the sanitizer configuration, and further removes any XSS-unsafe elements or attributes — whether or not they are allowed by the sanitizer configuration.
5858

59-
If no sanitizer is specified in the `options.sanitizer` parameter, `setHTML()` is used with the [default `Sanitizer` configuration](/en-US/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration).
59+
If no sanitizer is specified in the `options.sanitizer` parameter, `setHTML()` is used with the [default sanitizer configuration](/en-US/docs/Web/API/HTML_Sanitizer_API#default_sanitizer_configuration).
6060
This configuration is suitable for the majority of use cases as it prevents XSS attacks, as well as other attacks like clickjacking or spoofing.
6161

6262
A custom `Sanitizer` or `SanitizerConfig` can be specified to choose which elements, attributes, and comments are allowed or removed.

0 commit comments

Comments
 (0)