MCPcopy Index your code
hub / github.com/pallets/markupsafe

github.com/pallets/markupsafe @3.0.3

Chat with this repo
repository ↗ · DeepWiki ↗ · release 3.0.3 ↗ · + Follow
122 symbols 363 edges 13 files 14 documented · 11% 238 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

MarkupSafe

MarkupSafe implements a text object that escapes characters so it is safe to use in HTML and XML. Characters that have special meanings are replaced so that they display as the actual characters. This mitigates injection attacks, meaning untrusted user input can safely be displayed on a page.

Examples

>>> from markupsafe import Markup, escape

>>> # escape replaces special characters and wraps in Markup
>>> escape("<script>alert(document.cookie);</script>")
Markup('&lt;script&gt;alert(document.cookie);&lt;/script&gt;')

>>> # wrap in Markup to mark text "safe" and prevent escaping
>>> Markup("<strong>Hello</strong>")
Markup('<strong>hello</strong>')

>>> escape(Markup("<strong>Hello</strong>"))
Markup('<strong>hello</strong>')

>>> # Markup is a str subclass
>>> # methods and operators escape their arguments
>>> template = Markup("Hello <em>{name}</em>")
>>> template.format(name='"World"')
Markup('Hello <em>&#34;World&#34;</em>')

Donate

The Pallets organization develops and supports MarkupSafe and other popular packages. In order to grow the community of contributors and users, and allow the maintainers to devote more time to the projects, please donate today.

Contributing

See our detailed contributing documentation for many ways to contribute, including reporting issues, requesting features, asking or answering questions, and making PRs.

Core symbols most depended-on inside this repo

escape
called by 16
src/markupsafe/__init__.py
format
called by 10
src/markupsafe/__init__.py
escape
called by 9
src/markupsafe/__init__.py
unescape
called by 5
src/markupsafe/__init__.py
replace
called by 5
src/markupsafe/__init__.py
run_setup
called by 4
setup.py
show_message
called by 3
setup.py
soft_str
called by 3
src/markupsafe/__init__.py

Shape

Method 65
Function 40
Class 16
Route 1

Languages

Python95%
C5%

Modules by API surface

src/markupsafe/__init__.py58 symbols
tests/test_markupsafe.py34 symbols
tests/test_escape.py9 symbols
src/markupsafe/_speedups.c6 symbols
setup.py6 symbols
tests/test_exception_custom_html.py3 symbols
tests/test_leak.py2 symbols
tests/conftest.py2 symbols
tests/test_ext_init.py1 symbols
src/markupsafe/_native.py1 symbols

For agents

$ claude mcp add markupsafe \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact