@@ -335,6 +335,12 @@ def convert(self, source: str) -> str:
335335 [`ElementTree`][xml.etree.ElementTree.ElementTree] object has been serialized into text.
336336 5. The output is returned as a string.
337337
338+ !!! warning
339+ The Python-Markdown library does ***not*** sanitize its HTML output.
340+ If you are processing Markdown input from an untrusted source, it is your
341+ responsibility to ensure that it is properly sanitized. For more
342+ information see [Sanitizing HTML Output](../../sanitization.md).
343+
338344 """
339345
340346 # Fix up the source text
@@ -392,9 +398,9 @@ def convertFile(
392398 encoding : str | None = None ,
393399 ) -> Markdown :
394400 """
395- Converts a Markdown file and returns the HTML as a Unicode string .
401+ Read Markdown text from a file or stream and write HTML output to a file or stream .
396402
397- Decodes the file using the provided encoding (defaults to `utf-8`),
403+ Decodes the input file using the provided encoding (defaults to `utf-8`),
398404 passes the file content to markdown, and outputs the HTML to either
399405 the provided stream or the file with provided name, using the same
400406 encoding as the source file. The
@@ -410,6 +416,14 @@ def convertFile(
410416 output: File object or path. Writes to `stdout` if `None`.
411417 encoding: Encoding of input and output files. Defaults to `utf-8`.
412418
419+ !!! warning
420+ The Python-Markdown library does ***not*** sanitize its HTML output.
421+ As `Markdown.convertFile` writes directly to the file system, there is no
422+ easy way to sanitize the output from Python code. Therefore, it is
423+ recommended that the `Markdown.convertFile` method not be used on input
424+ from an untrusted source. For more information see [Sanitizing HTML
425+ Output](sanitization.md).
426+
413427 """
414428
415429 encoding = encoding or "utf-8"
@@ -477,14 +491,20 @@ def markdown(text: str, **kwargs: Any) -> str:
477491 Returns:
478492 A string in the specified output format.
479493
494+ !!! warning
495+ The Python-Markdown library does ***not*** sanitize its HTML output.
496+ If you are processing Markdown input from an untrusted source, it is your
497+ responsibility to ensure that it is properly sanitized. For more
498+ information see [Sanitizing HTML Output](sanitization.md).
499+
480500 """
481501 md = Markdown (** kwargs )
482502 return md .convert (text )
483503
484504
485505def markdownFromFile (** kwargs : Any ):
486506 """
487- Read Markdown text from a file and write output to a file or a stream.
507+ Read Markdown text from a file or stream and write HTML output to a file or stream.
488508
489509 This is a shortcut function which initializes an instance of [`Markdown`][markdown.Markdown],
490510 and calls the [`convertFile`][markdown.Markdown.convertFile] method rather than
@@ -496,6 +516,14 @@ def markdownFromFile(**kwargs: Any):
496516 encoding (str): Encoding of input and output.
497517 **kwargs: Any arguments accepted by the `Markdown` class.
498518
519+ !!! warning
520+ The Python-Markdown library does ***not*** sanitize its HTML output.
521+ As `markdown.markdownFromFile` writes directly to the file system, there is no
522+ easy way to sanitize the output from Python code. Therefore, it is
523+ recommended that the `markdown.markdownFromFile` function not be used on input
524+ from an untrusted source. For more information see [Sanitizing HTML
525+ Output](sanitization.md).
526+
499527 """
500528 md = Markdown (** kwargs )
501529 md .convertFile (kwargs .get ('input' , None ),
0 commit comments