diff options
author | robot-contrib <robot-contrib@yandex-team.com> | 2024-02-03 10:22:55 +0300 |
---|---|---|
committer | robot-contrib <robot-contrib@yandex-team.com> | 2024-02-03 10:37:15 +0300 |
commit | 0fd18e57c83709eee303a544bdc91337d7139e65 (patch) | |
tree | 0e55e6acb3f3141117e46e5919a5d5cad3c26375 | |
parent | 4cd7ee165b7f05e7f3988b2828e23ff617aba74e (diff) | |
download | ydb-0fd18e57c83709eee303a544bdc91337d7139e65.tar.gz |
Update contrib/python/MarkupSafe/py3 to 2.1.4
-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) |