• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

src/H30-Mar-2022-1,2231,011

CHANGES.rstH A D30-Mar-20221.8 KiB9857

LICENSE.rstH A D30-Mar-20221.4 KiB2923

MANIFEST.inH A D30-Mar-2022140 98

PKG-INFOH A D30-Mar-20224 KiB10280

README.rstH A D30-Mar-20222.1 KiB7049

setup.cfgH A D30-Mar-2022401 2821

setup.pyH A D30-Mar-20224.1 KiB126106

tox.iniH A D30-Mar-2022886 4539

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    >>> # escape replaces special characters and wraps in Markup
30    >>> escape('<script>alert(document.cookie);</script>')
31    Markup(u'&lt;script&gt;alert(document.cookie);&lt;/script&gt;')
32    >>> # wrap in Markup to mark text "safe" and prevent escaping
33    >>> Markup('<strong>Hello</strong>')
34    Markup('<strong>hello</strong>')
35    >>> escape(Markup('<strong>Hello</strong>'))
36    Markup('<strong>hello</strong>')
37    >>> # Markup is a text subclass (str on Python 3, unicode on Python 2)
38    >>> # methods and operators escape their arguments
39    >>> template = Markup("Hello <em>%s</em>")
40    >>> template % '"World"'
41    Markup('Hello <em>&#34;World&#34;</em>')
42
43
44Donate
45------
46
47The Pallets organization develops and supports MarkupSafe and other
48libraries that use it. In order to grow the community of contributors
49and users, and allow the maintainers to devote more time to the
50projects, `please donate today`_.
51
52.. _please donate today: https://palletsprojects.com/donate
53
54
55Links
56-----
57
58*   Website: https://palletsprojects.com/p/markupsafe/
59*   Documentation: https://markupsafe.palletsprojects.com/
60*   License: `BSD-3-Clause <https://github.com/pallets/markupsafe/blob/master/LICENSE.rst>`_
61*   Releases: https://pypi.org/project/MarkupSafe/
62*   Code: https://github.com/pallets/markupsafe
63*   Issue tracker: https://github.com/pallets/markupsafe/issues
64*   Test status:
65
66    *   Linux, Mac: https://travis-ci.org/pallets/markupsafe
67    *   Windows: https://ci.appveyor.com/project/pallets/markupsafe
68
69*   Test coverage: https://codecov.io/gh/pallets/markupsafe
70