|
| 1 | +Metadata-Version: 2.4 |
| 2 | +Name: MarkupSafe |
| 3 | +Version: 3.0.2 |
| 4 | +Summary: Safely add untrusted strings to HTML/XML markup. |
| 5 | +Maintainer-email: Pallets < [email protected]> |
| 6 | +License: Copyright 2010 Pallets |
| 7 | + |
| 8 | + Redistribution and use in source and binary forms, with or without |
| 9 | + modification, are permitted provided that the following conditions are |
| 10 | + met: |
| 11 | + |
| 12 | + 1. Redistributions of source code must retain the above copyright |
| 13 | + notice, this list of conditions and the following disclaimer. |
| 14 | + |
| 15 | + 2. Redistributions in binary form must reproduce the above copyright |
| 16 | + notice, this list of conditions and the following disclaimer in the |
| 17 | + documentation and/or other materials provided with the distribution. |
| 18 | + |
| 19 | + 3. Neither the name of the copyright holder nor the names of its |
| 20 | + contributors may be used to endorse or promote products derived from |
| 21 | + this software without specific prior written permission. |
| 22 | + |
| 23 | + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 24 | + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 25 | + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
| 26 | + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 27 | + HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 28 | + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
| 29 | + TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 30 | + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 31 | + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 32 | + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 33 | + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 34 | + |
| 35 | +Project-URL: Donate, https://palletsprojects.com/donate |
| 36 | +Project-URL: Documentation, https://markupsafe.palletsprojects.com/ |
| 37 | +Project-URL: Changes, https://markupsafe.palletsprojects.com/changes/ |
| 38 | +Project-URL: Source, https://github.com/pallets/markupsafe/ |
| 39 | +Project-URL: Chat, https://discord.gg/pallets |
| 40 | +Classifier: Development Status :: 5 - Production/Stable |
| 41 | +Classifier: Environment :: Web Environment |
| 42 | +Classifier: Intended Audience :: Developers |
| 43 | +Classifier: License :: OSI Approved :: BSD License |
| 44 | +Classifier: Operating System :: OS Independent |
| 45 | +Classifier: Programming Language :: Python |
| 46 | +Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content |
| 47 | +Classifier: Topic :: Text Processing :: Markup :: HTML |
| 48 | +Classifier: Typing :: Typed |
| 49 | +Requires-Python: >=3.9 |
| 50 | +Description-Content-Type: text/markdown |
| 51 | +License-File: LICENSE.txt |
| 52 | +Dynamic: license-file |
| 53 | + |
| 54 | +# MarkupSafe |
| 55 | + |
| 56 | +MarkupSafe implements a text object that escapes characters so it is |
| 57 | +safe to use in HTML and XML. Characters that have special meanings are |
| 58 | +replaced so that they display as the actual characters. This mitigates |
| 59 | +injection attacks, meaning untrusted user input can safely be displayed |
| 60 | +on a page. |
| 61 | + |
| 62 | + |
| 63 | +## Examples |
| 64 | + |
| 65 | +```pycon |
| 66 | +>>> from markupsafe import Markup, escape |
| 67 | + |
| 68 | +>>> # escape replaces special characters and wraps in Markup |
| 69 | +>>> escape("<script>alert(document.cookie);</script>") |
| 70 | +Markup('<script>alert(document.cookie);</script>') |
| 71 | + |
| 72 | +>>> # wrap in Markup to mark text "safe" and prevent escaping |
| 73 | +>>> Markup("<strong>Hello</strong>") |
| 74 | +Markup('<strong>hello</strong>') |
| 75 | + |
| 76 | +>>> escape(Markup("<strong>Hello</strong>")) |
| 77 | +Markup('<strong>hello</strong>') |
| 78 | + |
| 79 | +>>> # Markup is a str subclass |
| 80 | +>>> # methods and operators escape their arguments |
| 81 | +>>> template = Markup("Hello <em>{name}</em>") |
| 82 | +>>> template.format(name='"World"') |
| 83 | +Markup('Hello <em>"World"</em>') |
| 84 | +``` |
| 85 | + |
| 86 | +## Donate |
| 87 | + |
| 88 | +The Pallets organization develops and supports MarkupSafe and other |
| 89 | +popular packages. In order to grow the community of contributors and |
| 90 | +users, and allow the maintainers to devote more time to the projects, |
| 91 | +[please donate today][]. |
| 92 | + |
| 93 | +[please donate today]: https://palletsprojects.com/donate |
0 commit comments