Skip to content
Snippets Groups Projects
Commit 6bad6c6a authored by Piotr Ożarowski's avatar Piotr Ożarowski
Browse files

New upstream version 2.1.1

parent d648de80
No related branches found
No related tags found
No related merge requests found
Version 2.1.1
-------------
Released 2022-03-14
- Avoid ambiguous regex matches in ``striptags``. :pr:`293`
Version 2.1.0
-------------
Released 2022-02-17
- Drop support for Python 3.6. :pr:`262`
- Remove ``soft_unicode``, which was previously deprecated. Use
``soft_str`` instead. :pr:`261`
- Raise error on missing single placeholder during string
interpolation. :issue:`225`
- Disable speedups module for GraalPython. :issue:`277`
Version 2.0.1
-------------
......@@ -37,7 +58,7 @@ Released 2018-11-05
- Build wheels for Linux, Mac, and Windows, allowing systems without
a compiler to take advantage of the C extension speedups. :pr:`104`
- Use newer CPython API on Python 3, resulting in a 1.5x speedup.
:pr`64`
:pr:`64`
- ``escape`` wraps ``__html__`` result in ``Markup``, consistent with
documented behavior. :pr:`69`
......
Metadata-Version: 2.1
Name: MarkupSafe
Version: 2.0.1
Version: 2.1.1
Summary: Safely add untrusted strings to HTML/XML markup.
Home-page: https://palletsprojects.com/p/markupsafe/
Author: Armin Ronacher
......@@ -15,76 +15,6 @@ Project-URL: Source Code, https://github.com/pallets/markupsafe/
Project-URL: Issue Tracker, https://github.com/pallets/markupsafe/issues/
Project-URL: Twitter, https://twitter.com/PalletsTeam
Project-URL: Chat, https://discord.gg/pallets
Description: 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.
Installing
----------
Install and update using `pip`_:
.. code-block:: text
pip install -U MarkupSafe
.. _pip: https://pip.pypa.io/en/stable/quickstart/
Examples
--------
.. code-block:: pycon
>>> 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`_.
.. _please donate today: https://palletsprojects.com/donate
Links
-----
- Documentation: https://markupsafe.palletsprojects.com/
- Changes: https://markupsafe.palletsprojects.com/changes/
- PyPI Releases: https://pypi.org/project/MarkupSafe/
- Source Code: https://github.com/pallets/markupsafe/
- Issue Tracker: https://github.com/pallets/markupsafe/issues/
- Website: https://palletsprojects.com/p/markupsafe/
- Twitter: https://twitter.com/PalletsTeam
- Chat: https://discord.gg/pallets
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
......@@ -94,5 +24,78 @@ Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Text Processing :: Markup :: HTML
Requires-Python: >=3.6
Requires-Python: >=3.7
Description-Content-Type: text/x-rst
License-File: LICENSE.rst
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.
Installing
----------
Install and update using `pip`_:
.. code-block:: text
pip install -U MarkupSafe
.. _pip: https://pip.pypa.io/en/stable/getting-started/
Examples
--------
.. code-block:: pycon
>>> 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`_.
.. _please donate today: https://palletsprojects.com/donate
Links
-----
- Documentation: https://markupsafe.palletsprojects.com/
- Changes: https://markupsafe.palletsprojects.com/changes/
- PyPI Releases: https://pypi.org/project/MarkupSafe/
- Source Code: https://github.com/pallets/markupsafe/
- Issue Tracker: https://github.com/pallets/markupsafe/issues/
- Website: https://palletsprojects.com/p/markupsafe/
- Twitter: https://twitter.com/PalletsTeam
- Chat: https://discord.gg/pallets
......@@ -17,7 +17,7 @@ Install and update using `pip`_:
pip install -U MarkupSafe
.. _pip: https://pip.pypa.io/en/stable/quickstart/
.. _pip: https://pip.pypa.io/en/stable/getting-started/
Examples
......
......@@ -38,10 +38,10 @@ html_context = {
]
}
html_sidebars = {
"index": ["project.html", "localtoc.html", "searchbox.html"],
"**": ["localtoc.html", "relations.html", "searchbox.html"],
"index": ["project.html", "localtoc.html", "searchbox.html", "ethicalads.html"],
"**": ["localtoc.html", "relations.html", "searchbox.html", "ethicalads.html"],
}
singlehtml_sidebars = {"index": ["project.html", "localtoc.html"]}
singlehtml_sidebars = {"index": ["project.html", "localtoc.html", "ethicalads.html"]}
html_title = f"MarkupSafe Documentation ({version})"
html_show_sourcelink = False
......
# SHA1:54b5b77ec8c7a0064ffa93b2fd16cb0130ba177c
#
# This file is autogenerated by pip-compile
# This file is autogenerated by pip-compile-multi
# To update, run:
#
# pip-compile requirements/dev.in
# pip-compile-multi
#
alabaster==0.7.12
# via sphinx
appdirs==1.4.4
# via virtualenv
attrs==21.2.0
# via pytest
babel==2.9.1
# via sphinx
certifi==2020.12.5
# via requests
cfgv==3.2.0
-r docs.txt
-r tests.txt
-r typing.txt
cfgv==3.3.1
# via pre-commit
chardet==4.0.0
# via requests
click==8.0.0
# via pip-tools
distlib==0.3.1
click==8.0.3
# via
# pip-compile-multi
# pip-tools
distlib==0.3.4
# via virtualenv
docutils==0.17.1
# via sphinx
filelock==3.0.12
filelock==3.5.1
# via
# tox
# virtualenv
identify==2.2.4
identify==2.4.10
# via pre-commit
idna==2.10
# via requests
imagesize==1.2.0
# via sphinx
iniconfig==1.1.1
# via pytest
jinja2==3.0.0
# via sphinx
markupsafe==2.0.0
# via jinja2
mypy-extensions==0.4.3
# via mypy
mypy==0.812
# via -r requirements/typing.in
nodeenv==1.6.0
# via pre-commit
packaging==20.9
# via
# pallets-sphinx-themes
# pytest
# sphinx
# tox
pallets-sphinx-themes==2.0.0
# via -r requirements/docs.in
pep517==0.10.0
pep517==0.12.0
# via pip-tools
pip-tools==6.1.0
pip-compile-multi==2.4.3
# via -r requirements/dev.in
pluggy==0.13.1
# via
# pytest
# tox
pre-commit==2.12.1
pip-tools==6.5.1
# via pip-compile-multi
platformdirs==2.5.0
# via virtualenv
pre-commit==2.17.0
# via -r requirements/dev.in
py==1.10.0
# via
# pytest
# tox
pygments==2.9.0
# via sphinx
pyparsing==2.4.7
# via packaging
pytest==6.2.4
# via -r requirements/tests.in
pytz==2021.1
# via babel
pyyaml==5.4.1
pyyaml==6.0
# via pre-commit
requests==2.25.1
# via sphinx
six==1.16.0
# via
# tox
# virtualenv
snowballstemmer==2.1.0
# via sphinx
sphinx-issues==1.2.0
# via -r requirements/docs.in
git+https://github.com/sphinx-doc/sphinx.git@96dbe5e3
# via
# -r requirements/docs.in
# pallets-sphinx-themes
# sphinx-issues
# sphinxcontrib-log-cabinet
sphinxcontrib-applehelp==1.0.2
# via sphinx
sphinxcontrib-devhelp==1.0.2
# via sphinx
sphinxcontrib-htmlhelp==1.0.3
# via sphinx
sphinxcontrib-jsmath==1.0.1
# via sphinx
sphinxcontrib-log-cabinet==1.0.1
# via -r requirements/docs.in
sphinxcontrib-qthelp==1.0.3
# via sphinx
sphinxcontrib-serializinghtml==1.1.4
# via sphinx
toml==0.10.2
# via
# pep517
# pre-commit
# pytest
# tox
tox==3.23.1
toposort==1.7
# via pip-compile-multi
tox==3.24.5
# via -r requirements/dev.in
typed-ast==1.4.3
# via mypy
typing-extensions==3.10.0.0
# via mypy
urllib3==1.26.4
# via requests
virtualenv==20.4.6
virtualenv==20.13.1
# via
# pre-commit
# tox
wheel==0.37.1
# via pip-tools
# The following packages are considered to be unsafe in a requirements file:
# pip
......
# SHA1:45c590f97fe95b8bdc755eef796e91adf5fbe4ea
#
# This file is autogenerated by pip-compile
# This file is autogenerated by pip-compile-multi
# To update, run:
#
# pip-compile requirements/docs.in
# pip-compile-multi
#
alabaster==0.7.12
# via sphinx
babel==2.9.1
# via sphinx
certifi==2020.12.5
certifi==2021.10.8
# via requests
chardet==4.0.0
charset-normalizer==2.0.12
# via requests
docutils==0.17.1
# via sphinx
idna==2.10
idna==3.3
# via requests
imagesize==1.2.0
imagesize==1.3.0
# via sphinx
jinja2==3.0.0
jinja2==3.0.3
# via sphinx
markupsafe==2.0.0
markupsafe==2.0.1
# via jinja2
packaging==20.9
packaging==21.3
# via
# pallets-sphinx-themes
# sphinx
pallets-sphinx-themes==2.0.0
pallets-sphinx-themes==2.0.2
# via -r requirements/docs.in
pygments==2.9.0
pygments==2.11.2
# via sphinx
pyparsing==2.4.7
pyparsing==3.0.7
# via packaging
pytz==2021.1
pytz==2021.3
# via babel
requests==2.25.1
requests==2.27.1
# via sphinx
snowballstemmer==2.1.0
snowballstemmer==2.2.0
# via sphinx
sphinx-issues==1.2.0
# via -r requirements/docs.in
git+https://github.com/sphinx-doc/sphinx.git@96dbe5e3
sphinx==4.4.0
# via
# -r requirements/docs.in
# pallets-sphinx-themes
# sphinx-issues
# sphinxcontrib-log-cabinet
sphinx-issues==3.0.1
# via -r requirements/docs.in
sphinxcontrib-applehelp==1.0.2
# via sphinx
sphinxcontrib-devhelp==1.0.2
# via sphinx
sphinxcontrib-htmlhelp==1.0.3
sphinxcontrib-htmlhelp==2.0.0
# via sphinx
sphinxcontrib-jsmath==1.0.1
# via sphinx
......@@ -58,10 +59,7 @@ sphinxcontrib-log-cabinet==1.0.1
# via -r requirements/docs.in
sphinxcontrib-qthelp==1.0.3
# via sphinx
sphinxcontrib-serializinghtml==1.1.4
sphinxcontrib-serializinghtml==1.1.5
# via sphinx
urllib3==1.26.4
urllib3==1.26.8
# via requests
# The following packages are considered to be unsafe in a requirements file:
# setuptools
# SHA1:0eaa389e1fdb3a1917c0f987514bd561be5718ee
#
# This file is autogenerated by pip-compile
# This file is autogenerated by pip-compile-multi
# To update, run:
#
# pip-compile requirements/tests.in
# pip-compile-multi
#
attrs==21.2.0
attrs==21.4.0
# via pytest
iniconfig==1.1.1
# via pytest
packaging==20.9
packaging==21.3
# via pytest
pluggy==0.13.1
pluggy==1.0.0
# via pytest
py==1.10.0
py==1.11.0
# via pytest
pyparsing==2.4.7
pyparsing==3.0.7
# via packaging
pytest==6.2.4
pytest==7.0.1
# via -r requirements/tests.in
toml==0.10.2
tomli==2.0.1
# via pytest
# SHA1:7983aaa01d64547827c20395d77e248c41b2572f
#
# This file is autogenerated by pip-compile
# This file is autogenerated by pip-compile-multi
# To update, run:
#
# pip-compile requirements/typing.in
# pip-compile-multi
#
mypy==0.931
# via -r requirements/typing.in
mypy-extensions==0.4.3
# via mypy
mypy==0.812
# via -r requirements/typing.in
typed-ast==1.4.3
tomli==2.0.1
# via mypy
typing-extensions==3.10.0.0
typing-extensions==4.1.1
# via mypy
......@@ -32,8 +32,8 @@ classifiers =
[options]
packages = find:
package_dir = = src
include_package_data = true
python_requires = >= 3.6
include_package_data = True
python_requires = >= 3.7
[options.packages.find]
where = src
......@@ -44,7 +44,7 @@ filterwarnings =
error
[coverage:run]
branch = true
branch = True
source =
markupsafe
tests
......@@ -55,7 +55,7 @@ source =
*/site-packages
[flake8]
select = B, E, F, W, B9
select = B, E, F, W, B9, ISC
ignore =
E203
E501
......@@ -65,7 +65,8 @@ max-line-length = 80
[mypy]
files = src/markupsafe
python_version = 3.6
python_version = 3.7
show_error_codes = True
disallow_subclassing_any = True
disallow_untyped_calls = True
disallow_untyped_defs = True
......
import os
import platform
import sys
from distutils.errors import CCompilerError
from distutils.errors import DistutilsExecError
from distutils.errors import DistutilsPlatformError
from setuptools import Extension
from setuptools import setup
from setuptools.command.build_ext import build_ext
......@@ -22,18 +22,18 @@ class ve_build_ext(build_ext):
def run(self):
try:
build_ext.run(self)
except DistutilsPlatformError:
raise BuildFailed()
except DistutilsPlatformError as e:
raise BuildFailed() from e
def build_extension(self, ext):
try:
build_ext.build_extension(self, ext)
except (CCompilerError, DistutilsExecError, DistutilsPlatformError):
raise BuildFailed()
except ValueError:
except (CCompilerError, DistutilsExecError, DistutilsPlatformError) as e:
raise BuildFailed() from e
except ValueError as e:
# this can happen on Windows 64 bit, see Python issue 7511
if "'path'" in str(sys.exc_info()[1]): # works with Python 2 and 3
raise BuildFailed()
raise BuildFailed() from e
raise
......@@ -52,7 +52,11 @@ def show_message(*lines):
print("=" * 74)
supports_speedups = platform.python_implementation() not in {"PyPy", "Jython"}
supports_speedups = platform.python_implementation() not in {
"PyPy",
"Jython",
"GraalVM",
}
if os.environ.get("CIBUILDWHEEL", "0") == "1" and supports_speedups:
run_setup(True)
......
Metadata-Version: 2.1
Name: MarkupSafe
Version: 2.0.1
Version: 2.1.1
Summary: Safely add untrusted strings to HTML/XML markup.
Home-page: https://palletsprojects.com/p/markupsafe/
Author: Armin Ronacher
......@@ -15,76 +15,6 @@ Project-URL: Source Code, https://github.com/pallets/markupsafe/
Project-URL: Issue Tracker, https://github.com/pallets/markupsafe/issues/
Project-URL: Twitter, https://twitter.com/PalletsTeam
Project-URL: Chat, https://discord.gg/pallets
Description: 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.
Installing
----------
Install and update using `pip`_:
.. code-block:: text
pip install -U MarkupSafe
.. _pip: https://pip.pypa.io/en/stable/quickstart/
Examples
--------
.. code-block:: pycon
>>> 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`_.
.. _please donate today: https://palletsprojects.com/donate
Links
-----
- Documentation: https://markupsafe.palletsprojects.com/
- Changes: https://markupsafe.palletsprojects.com/changes/
- PyPI Releases: https://pypi.org/project/MarkupSafe/
- Source Code: https://github.com/pallets/markupsafe/
- Issue Tracker: https://github.com/pallets/markupsafe/issues/
- Website: https://palletsprojects.com/p/markupsafe/
- Twitter: https://twitter.com/PalletsTeam
- Chat: https://discord.gg/pallets
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
......@@ -94,5 +24,78 @@ Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Text Processing :: Markup :: HTML
Requires-Python: >=3.6
Requires-Python: >=3.7
Description-Content-Type: text/x-rst
License-File: LICENSE.rst
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.
Installing
----------
Install and update using `pip`_:
.. code-block:: text
pip install -U MarkupSafe
.. _pip: https://pip.pypa.io/en/stable/getting-started/
Examples
--------
.. code-block:: pycon
>>> 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`_.
.. _please donate today: https://palletsprojects.com/donate
Links
-----
- Documentation: https://markupsafe.palletsprojects.com/
- Changes: https://markupsafe.palletsprojects.com/changes/
- PyPI Releases: https://pypi.org/project/MarkupSafe/
- Source Code: https://github.com/pallets/markupsafe/
- Issue Tracker: https://github.com/pallets/markupsafe/issues/
- Website: https://palletsprojects.com/p/markupsafe/
- Twitter: https://twitter.com/PalletsTeam
- Chat: https://discord.gg/pallets
......@@ -11,9 +11,10 @@ if t.TYPE_CHECKING:
pass
__version__ = "2.0.1"
__version__ = "2.1.1"
_striptags_re = re.compile(r"(<!--.*?-->|<[^>]*>)")
_strip_comments_re = re.compile(r"<!--.*?-->")
_strip_tags_re = re.compile(r"<.*?>")
def _simple_escaping_wrapper(name: str) -> t.Callable[..., "Markup"]:
......@@ -92,19 +93,24 @@ class Markup(str):
return NotImplemented
def __mul__(self, num: int) -> "Markup":
def __mul__(self, num: "te.SupportsIndex") -> "Markup":
if isinstance(num, int):
return self.__class__(super().__mul__(num))
return NotImplemented # type: ignore
return NotImplemented
__rmul__ = __mul__
def __mod__(self, arg: t.Any) -> "Markup":
if isinstance(arg, tuple):
# a tuple of arguments, each wrapped
arg = tuple(_MarkupEscapeHelper(x, self.escape) for x in arg)
else:
elif hasattr(type(arg), "__getitem__") and not isinstance(arg, str):
# a mapping of arguments, wrapped
arg = _MarkupEscapeHelper(arg, self.escape)
else:
# a single argument, wrapped with the helper and a tuple
arg = (_MarkupEscapeHelper(arg, self.escape),)
return self.__class__(super().__mod__(arg))
......@@ -153,8 +159,11 @@ class Markup(str):
>>> Markup("Main &raquo;\t<em>About</em>").striptags()
'Main » About'
"""
stripped = " ".join(_striptags_re.sub("", self).split())
return Markup(stripped).unescape()
# Use two regexes to avoid ambiguous matches.
value = _strip_comments_re.sub("", self)
value = _strip_tags_re.sub("", value)
value = " ".join(value.split())
return Markup(value).unescape()
@classmethod
def escape(cls, s: t.Any) -> "Markup":
......@@ -280,9 +289,7 @@ try:
from ._speedups import escape as escape
from ._speedups import escape_silent as escape_silent
from ._speedups import soft_str as soft_str
from ._speedups import soft_unicode
except ImportError:
from ._native import escape as escape
from ._native import escape_silent as escape_silent # noqa: F401
from ._native import soft_str as soft_str # noqa: F401
from ._native import soft_unicode # noqa: F401
......@@ -61,15 +61,3 @@ def soft_str(s: t.Any) -> str:
return str(s)
return s
def soft_unicode(s: t.Any) -> str:
import warnings
warnings.warn(
"'soft_unicode' has been renamed to 'soft_str'. The old name"
" will be removed in MarkupSafe 2.1.",
DeprecationWarning,
stacklevel=2,
)
return soft_str(s)
......@@ -254,19 +254,6 @@ soft_str(PyObject *self, PyObject *s)
}
static PyObject*
soft_unicode(PyObject *self, PyObject *s)
{
PyErr_WarnEx(
PyExc_DeprecationWarning,
"'soft_unicode' has been renamed to 'soft_str'. The old name"
" will be removed in MarkupSafe 2.1.",
2
);
return soft_str(self, s);
}
static PyMethodDef module_methods[] = {
{
"escape",
......@@ -308,12 +295,6 @@ static PyMethodDef module_methods[] = {
">>> escape(soft_str(value))\n"
"Markup('&lt;User 1&gt;')\n"
},
{
"soft_unicode",
(PyCFunction)soft_unicode,
METH_O,
""
},
{NULL, NULL, 0, NULL} /* Sentinel */
};
......
......@@ -35,8 +35,3 @@ def escape_silent(_mod):
@pytest.fixture(scope="session")
def soft_str(_mod):
return _mod.soft_str
@pytest.fixture(scope="session")
def soft_unicode(_mod):
return _mod.soft_unicode
......@@ -45,6 +45,12 @@ def test_html_interop():
assert result == "<strong><em>awesome</em></strong>"
@pytest.mark.parametrize("args", ["foo", 42, ("foo", 42)])
def test_missing_interpol(args):
with pytest.raises(TypeError):
Markup("<em></em>") % args
def test_tuple_interpol():
result = Markup("<em>%s:%s</em>") % ("<foo>", "<bar>")
expect = Markup("<em>&lt;foo&gt;:&lt;bar&gt;</em>")
......@@ -63,7 +69,15 @@ def test_dict_interpol():
def test_escaping(escape):
assert escape("\"<>&'") == "&#34;&lt;&gt;&amp;&#39;"
assert Markup("<em>Foo &amp; Bar</em>").striptags() == "Foo & Bar"
assert (
Markup(
"<!-- outer comment -->"
"<em>Foo &amp; Bar"
"<!-- inner comment about <em> -->"
"</em>"
).striptags()
== "Foo & Bar"
)
def test_unescape():
......@@ -178,8 +192,3 @@ def test_soft_str(soft_str):
assert type(soft_str("")) is str
assert type(soft_str(Markup())) is Markup
assert type(soft_str(15)) is str
def test_soft_unicode_deprecated(soft_unicode):
with pytest.warns(DeprecationWarning):
assert type(soft_unicode(Markup())) is Markup
[tox]
envlist =
py{39,38,37,36,py3}
py3{11,10,9,8,7},pypy3{8,7}
style
typing
docs
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment