Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | - | - | ||||
.github/workflows/ | 03-May-2024 | - | 82 | 80 | ||
bench/ | 03-May-2024 | - | 72 | 47 | ||
docs/ | 03-May-2024 | - | 314 | 213 | ||
requirements/ | 03-May-2024 | - | 99 | 91 | ||
src/markupsafe/ | 03-May-2024 | - | 693 | 566 | ||
tests/ | 03-May-2024 | - | 307 | 214 | ||
.editorconfig | D | 03-May-2024 | 243 | 17 | 13 | |
.gitignore | D | 03-May-2024 | 147 | 19 | 18 | |
.pre-commit-config.yaml | D | 03-May-2024 | 715 | 27 | 26 | |
.readthedocs.yaml | D | 03-May-2024 | 131 | 9 | 8 | |
Android.bp | D | 03-May-2024 | 681 | 34 | 31 | |
CHANGES.rst | D | 03-May-2024 | 1.8 KiB | 102 | 59 | |
LICENSE.rst | D | 03-May-2024 | 1.4 KiB | 29 | 23 | |
MANIFEST.in | D | 03-May-2024 | 125 | 8 | 7 | |
README.rst | D | 03-May-2024 | 1.9 KiB | 69 | 46 | |
setup.cfg | D | 03-May-2024 | 1.7 KiB | 71 | 64 | |
setup.py | D | 03-May-2024 | 2.2 KiB | 80 | 64 | |
tox.ini | D | 03-May-2024 | 440 | 20 | 16 |
README.rst
1MarkupSafe 2========== 3 4MarkupSafe implements a text object that escapes characters so it is 5safe to use in HTML and XML. Characters that have special meanings are 6replaced so that they display as the actual characters. This mitigates 7injection attacks, meaning untrusted user input can safely be displayed 8on a page. 9 10 11Installing 12---------- 13 14Install and update using `pip`_: 15 16.. code-block:: text 17 18 pip install -U MarkupSafe 19 20.. _pip: https://pip.pypa.io/en/stable/quickstart/ 21 22 23Examples 24-------- 25 26.. code-block:: pycon 27 28 >>> from markupsafe import Markup, escape 29 30 >>> # escape replaces special characters and wraps in Markup 31 >>> escape("<script>alert(document.cookie);</script>") 32 Markup('<script>alert(document.cookie);</script>') 33 34 >>> # wrap in Markup to mark text "safe" and prevent escaping 35 >>> Markup("<strong>Hello</strong>") 36 Markup('<strong>hello</strong>') 37 38 >>> escape(Markup("<strong>Hello</strong>")) 39 Markup('<strong>hello</strong>') 40 41 >>> # Markup is a str subclass 42 >>> # methods and operators escape their arguments 43 >>> template = Markup("Hello <em>{name}</em>") 44 >>> template.format(name='"World"') 45 Markup('Hello <em>"World"</em>') 46 47 48Donate 49------ 50 51The Pallets organization develops and supports MarkupSafe and other 52libraries that use it. In order to grow the community of contributors 53and users, and allow the maintainers to devote more time to the 54projects, `please donate today`_. 55 56.. _please donate today: https://palletsprojects.com/donate 57 58 59Links 60----- 61 62* Website: https://palletsprojects.com/p/markupsafe/ 63* Documentation: https://markupsafe.palletsprojects.com/ 64* Releases: https://pypi.org/project/MarkupSafe/ 65* Code: https://github.com/pallets/markupsafe 66* Issue tracker: https://github.com/pallets/markupsafe/issues 67* Test status: https://dev.azure.com/pallets/markupsafe/_build 68* Official chat: https://discord.gg/t6rrQZH 69