diff options
author | robot-contrib <robot-contrib@yandex-team.com> | 2024-02-03 10:22:55 +0300 |
---|---|---|
committer | Alexander Smirnov <alex@ydb.tech> | 2024-02-09 19:17:26 +0300 |
commit | 880021255b8112bf9d01973b6fcfe81064c28036 (patch) | |
tree | 0c4e708d5d20f6bcf67e8c637334300e43e365e9 /contrib/python | |
parent | 4e6031f845d76fbb105bbee3f2a36b796b040c4d (diff) | |
download | ydb-880021255b8112bf9d01973b6fcfe81064c28036.tar.gz |
Update contrib/python/MarkupSafe/py3 to 2.1.4
Diffstat (limited to 'contrib/python')
-rw-r--r-- | contrib/python/MarkupSafe/py3/.dist-info/METADATA | 2 | ||||
-rw-r--r-- | contrib/python/MarkupSafe/py3/markupsafe/__init__.py | 45 | ||||
-rw-r--r-- | contrib/python/MarkupSafe/py3/ya.make | 2 |
3 files changed, 38 insertions, 11 deletions
diff --git a/contrib/python/MarkupSafe/py3/.dist-info/METADATA b/contrib/python/MarkupSafe/py3/.dist-info/METADATA index bced165239..c221b8e50e 100644 --- a/contrib/python/MarkupSafe/py3/.dist-info/METADATA +++ b/contrib/python/MarkupSafe/py3/.dist-info/METADATA @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: MarkupSafe -Version: 2.1.3 +Version: 2.1.4 Summary: Safely add untrusted strings to HTML/XML markup. Home-page: https://palletsprojects.com/p/markupsafe/ Maintainer: Pallets diff --git a/contrib/python/MarkupSafe/py3/markupsafe/__init__.py b/contrib/python/MarkupSafe/py3/markupsafe/__init__.py index 21d3196038..2f401a8153 100644 --- a/contrib/python/MarkupSafe/py3/markupsafe/__init__.py +++ b/contrib/python/MarkupSafe/py3/markupsafe/__init__.py @@ -1,5 +1,4 @@ import functools -import re import string import sys import typing as t @@ -14,10 +13,7 @@ if t.TYPE_CHECKING: _P = te.ParamSpec("_P") -__version__ = "2.1.3" - -_strip_comments_re = re.compile(r"<!--.*?-->", re.DOTALL) -_strip_tags_re = re.compile(r"<.*?>", re.DOTALL) +__version__ = "2.1.4" def _simple_escaping_wrapper(func: "t.Callable[_P, str]") -> "t.Callable[_P, Markup]": @@ -162,10 +158,41 @@ class Markup(str): >>> Markup("Main »\t<em>About</em>").striptags() 'Main ยป About' """ - # Use two regexes to avoid ambiguous matches. - value = _strip_comments_re.sub("", self) - value = _strip_tags_re.sub("", value) - value = " ".join(value.split()) + # collapse spaces + value = " ".join(self.split()) + + # Look for comments then tags separately. Otherwise, a comment that + # contains a tag would end early, leaving some of the comment behind. + + while True: + # keep finding comment start marks + start = value.find("<!--") + + if start == -1: + break + + # find a comment end mark beyond the start, otherwise stop + end = value.find("-->", start) + + if end == -1: + break + + value = f"{value[:start]}{value[end + 3:]}" + + # remove tags using the same method + while True: + start = value.find("<") + + if start == -1: + break + + end = value.find(">", start) + + if end == -1: + break + + value = f"{value[:start]}{value[end + 1:]}" + return self.__class__(value).unescape() @classmethod diff --git a/contrib/python/MarkupSafe/py3/ya.make b/contrib/python/MarkupSafe/py3/ya.make index 453504e572..3583a8035e 100644 --- a/contrib/python/MarkupSafe/py3/ya.make +++ b/contrib/python/MarkupSafe/py3/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(2.1.3) +VERSION(2.1.4) LICENSE(BSD-3-Clause) |