@@ -31,36 +31,10 @@ method appropriately ([see below](#convert)).
3131
3232 The Python-Markdown library does ***not*** sanitize its HTML output. If
3333 you are processing Markdown input from an untrusted source, it is your
34- responsibility to ensure that it is properly sanitized. See [Markdown and
35- XSS] for an overview of some of the dangers and [Improper markup
36- sanitization in popular software] for notes on best practices to ensure
37- HTML is properly sanitized.
38-
39- The developers of Python-Markdown recommend using [JustHTML] as a
40- sanitizer on the output of `markdown.markdown`. JustHTML includes a
41- built-in HTML sanitizer. When you pass the HTML output through JustHTML
42- (`JustHTML(markdown.markdown(text), fragment=True).to_html())`), it
43- is sanitized by default according to a strict [allow list policy]. The
44- policy can be [customized] if necessary.
45-
46- If you cannot use JustHTML for some reason, some alternatives include
47- [`nh3`][nh3] or [`bleach`][bleach][^1]. However, be aware that those
48- libraries will not be sufficient in themselves and will require
49- customization. Some useful lists of allowed tags and attributes can be
50- found in the [`bleach-allowlist`][bleach-allowlist] library, which should
51- work with either sanitizer.
52-
53-
54- [ Markdown and XSS ] : https://michelf.ca/blog/2010/markdown-and-xss/
55- [ Improper markup sanitization in popular software ] : https://github.com/ChALkeR/notes/blob/master/Improper-markup-sanitization.md
56- [ JustHTML ] : https://emilstenstrom.github.io/justhtml/
57- [ allow list policy ] : https://emilstenstrom.github.io/justhtml/html-cleaning.html#default-sanitization-policy
58- [ customized ] : https://emilstenstrom.github.io/justhtml/html-cleaning.html#use-a-custom-sanitization-policy
59- [ nh3 ] : https://nh3.readthedocs.io/en/latest/
60- [ bleach ] : http://bleach.readthedocs.org/en/latest/
61- [ bleach-allowlist ] : https://github.com/yourcelf/bleach-allowlist
62- [ ^ 1 ] : Note that the [ bleach] project has been [ deprecated] ( https://github.com/mozilla/bleach/issues/698 ) .
63- However, it may be the only option for some users.
34+ responsibility to ensure that it is properly sanitized. For more
35+ information see [Sanitizing HTML Output].
36+
37+ [ Sanitizing HTML Output ] : sanitization.md
6438
6539The following options are available on the ` markdown.markdown ` function:
6640
@@ -216,17 +190,12 @@ __tab_length__{: #tab_length }:
216190
217191!!! warning
218192
219- The Python-Markdown library does ***not*** sanitize its HTML output. If
220- you are processing Markdown input from an untrusted source, it is your
221- responsibility to ensure that it is properly sanitized. See [Markdown and
222- XSS] for an overview of some of the dangers and [Improper markup
223- sanitization in popular software] for notes on best practices to ensure
224- HTML is properly sanitized.
225-
226- As `markdown.markdownFromFile` writes directly to the file system, there
227- is no easy way to sanitize the output from Python code. Therefore, it is
193+ The Python-Markdown library does ***not*** sanitize its HTML output. As
194+ `markdown.markdownFromFile` writes directly to the file system, there is
195+ no easy way to sanitize the output from Python code. Therefore, it is
228196 recommended that the `markdown.markdownFromFile` function not be used on
229- input from an untrusted source.
197+ input from an untrusted source. For more information see [Sanitizing HTML
198+ Output].
230199
231200With a few exceptions, ` markdown.markdownFromFile ` accepts the same options as
232201` markdown.markdown ` . It does ** not** accept a ` text ` (or Unicode) string.
@@ -284,24 +253,8 @@ string must be passed to one of two instance methods.
284253
285254 The Python-Markdown library does ***not*** sanitize its HTML output. If
286255 you are processing Markdown input from an untrusted source, it is your
287- responsibility to ensure that it is properly sanitized. See [Markdown and
288- XSS] for an overview of some of the dangers and [Improper markup
289- sanitization in popular software] for notes on best practices to ensure
290- HTML is properly sanitized.
291-
292- The developers of Python-Markdown recommend using [JustHTML] as a
293- sanitizer on the output of `Markdown.convert`. JustHTML includes a
294- built-in HTML sanitizer. When you pass the HTML output through JustHTML
295- (`JustHTML(md.convert(text), fragment=True).to_html())`), it
296- is sanitized by default according to a strict [allow list policy]. The
297- policy can be [customized] if necessary.
298-
299- If you cannot use JustHTML for some reason, some alternatives include
300- [`nh3`][nh3] or [`bleach`][bleach][^1]. However, be aware that those
301- libraries will not be sufficient in themselves and will require
302- customization. Some useful lists of allowed tags and attributes can be
303- found in the [`bleach-allowlist`][bleach-allowlist] library, which should
304- work with either sanitizer.
256+ responsibility to ensure that it is properly sanitized. For more
257+ information see [Sanitizing HTML Output].
305258
306259The ` source ` text must meet the same requirements as the [ ` text ` ] ( #text )
307260argument of the [ ` markdown.markdown ` ] ( #markdown ) function.
@@ -334,17 +287,12 @@ html3 = md.reset().convert(text3)
334287
335288!!! warning
336289
337- The Python-Markdown library does ***not*** sanitize its HTML output. If
338- you are processing Markdown input from an untrusted source, it is your
339- responsibility to ensure that it is properly sanitized. See [Markdown and
340- XSS] for an overview of some of the dangers and [Improper markup
341- sanitization in popular software] for notes on best practices to ensure
342- HTML is properly sanitized.
343-
344- As `Markdown.convertFile` writes directly to the file system, there
345- is no easy way to sanitize the output from Python code. Therefore, it is
346- recommended that the `Markdown.convertFile` method not be used on
347- input from an untrusted source.
290+ The Python-Markdown library does ***not*** sanitize its HTML output. As
291+ `Markdown.convertFile` writes directly to the file system, there is no
292+ easy way to sanitize the output from Python code. Therefore, it is
293+ recommended that the `Markdown.convertFile` method not be used on input
294+ from an untrusted source. For more information see [Sanitizing HTML
295+ Output].
348296
349297The arguments of this method are identical to the arguments of the same
350298name on the ` markdown.markdownFromFile ` function ([ ` input ` ] ( #input ) ,
0 commit comments