diff --git a/python-yarl.changes b/python-yarl.changes index 34b3874..ced7ab3 100644 --- a/python-yarl.changes +++ b/python-yarl.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Tue Feb 23 17:02:42 UTC 2021 - Matej Cepl + +- Add tests_overcome_bpo42967.patch to over effects of bpo#42967, + which forbade mixing amps and semicolons in query strings as + separators. + ------------------------------------------------------------------- Sat Dec 19 10:06:48 UTC 2020 - Dirk Müller diff --git a/python-yarl.spec b/python-yarl.spec index 28bcfe2..d11c068 100644 --- a/python-yarl.spec +++ b/python-yarl.spec @@ -1,7 +1,7 @@ # # spec file for package python-yarl # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -26,6 +26,10 @@ License: Apache-2.0 Group: Development/Languages/Python URL: https://github.com/aio-libs/yarl/ Source: https://files.pythonhosted.org/packages/source/y/yarl/yarl-%{version}.tar.gz +# PATCH-FIX-UPSTREAM tests_overcome_bpo42967.patch bsc#[0-9]+ mcepl@suse.com +# Overcome effects of bpo#42967, which forbade mixing amps and +# semicolons in query strings as separators. +Patch0: tests_overcome_bpo42967.patch BuildRequires: %{python_module Cython} BuildRequires: %{python_module devel} BuildRequires: %{python_module idna >= 2.0} @@ -46,7 +50,7 @@ Requires: python-typing_extensions >= 3.7.4 The module provides a URL class for url parsing and changing. %prep -%setup -q -n yarl-%{version} +%autosetup -p1 -n yarl-%{version} %build export CFLAGS="%{optflags}" diff --git a/tests_overcome_bpo42967.patch b/tests_overcome_bpo42967.patch new file mode 100644 index 0000000..8c6bb7a --- /dev/null +++ b/tests_overcome_bpo42967.patch @@ -0,0 +1,65 @@ +--- a/yarl/_url.py ++++ b/yarl/_url.py +@@ -1,4 +1,5 @@ + import functools ++import inspect + import sys + import warnings + from collections.abc import Mapping, Sequence +@@ -142,7 +143,7 @@ class URL: + _PATH_UNQUOTER = _Unquoter(unsafe="+") + _QS_UNQUOTER = _Unquoter(qs=True) + +- def __new__(cls, val="", *, encoded=False, strict=None): ++ def __new__(cls, val="", *, encoded=False, strict=None, separator='&'): + if strict is not None: # pragma: no cover + warnings.warn("strict parameter is ignored") + if type(val) is cls: +@@ -157,6 +158,8 @@ class URL: + else: + raise TypeError("Constructor parameter should be str") + ++ cls.qs_sep = separator ++ + if not encoded: + if not val[1]: # netloc + netloc = "" +@@ -551,7 +554,12 @@ class URL: + Empty value if URL has no query part. + + """ +- ret = MultiDict(parse_qsl(self.raw_query_string, keep_blank_values=True)) ++ if 'separator' in inspect.signature(parse_qsl).parameters: ++ qs_dict = parse_qsl(self.raw_query_string, ++ keep_blank_values=True, separator=self.qs_sep) ++ else: ++ qs_dict = parse_qsl(self.raw_query_string, keep_blank_values=True) ++ ret = MultiDict(qs_dict) + return MultiDictProxy(ret) + + @property +@@ -988,7 +996,12 @@ class URL: + def update_query(self, *args, **kwargs): + """Return a new URL with query part updated.""" + s = self._get_str_query(*args, **kwargs) +- new_query = MultiDict(parse_qsl(s, keep_blank_values=True)) ++ if 'separator' in inspect.signature(parse_qsl).parameters: ++ qs_dict = parse_qsl(s, keep_blank_values=True, ++ separator=self.qs_sep) ++ else: ++ qs_dict = parse_qsl(s, keep_blank_values=True) ++ new_query = MultiDict(qs_dict) + query = MultiDict(self.query) + query.update(new_query) + +--- a/tests/test_url_query.py ++++ b/tests/test_url_query.py +@@ -63,7 +63,7 @@ def test_ampersand_as_value(): + + + def test_semicolon_as_separator(): +- u = URL("http://127.0.0.1/?a=1;b=2") ++ u = URL("http://127.0.0.1/?a=1;b=2", separator=';') + assert len(u.query) == 2 + +