Sync from SUSE:SLFO:Main python-cookies revision 0289cd653485edccf34db5c94f6a5b1e

This commit is contained in:
Adrian Schröter 2024-05-03 20:24:22 +02:00
commit 18f22a451c
7 changed files with 423 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

19
LICENSE Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 2011 Sasha Hart.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

BIN
cookies-2.2.1.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,13 @@
Index: cookies-2.2.1/setup.py
===================================================================
--- cookies-2.2.1.orig/setup.py
+++ cookies-2.2.1/setup.py
@@ -25,7 +25,7 @@ setup(
author="Sasha Hart",
author_email="s@sashahart.net",
url="https://github.com/sashahart/cookies",
- py_modules=['cookies', 'test_cookies'],
+ py_modules=['cookies'],
description="Friendlier RFC 6265-compliant cookie parser/renderer",
long_description=open('README').read(),
classifiers=[

50
python-cookies.changes Normal file
View File

@ -0,0 +1,50 @@
-------------------------------------------------------------------
Fri Apr 21 12:23:45 UTC 2023 - Dirk Müller <dmueller@suse.com>
- add sle15_python_module_pythons (jsc#PED-68)
-------------------------------------------------------------------
Thu Apr 13 22:40:40 UTC 2023 - Matej Cepl <mcepl@suse.com>
- Make calling of %{sle15modernpython} optional.
-------------------------------------------------------------------
Fri Feb 1 10:02:46 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com>
- Apply patch to fix build on python3.7:
* python37.patch
-------------------------------------------------------------------
Thu Oct 18 09:36:51 UTC 2018 - Tomáš Chvátal <tchvatal@suse.com>
- Upstream moved to gitlab
-------------------------------------------------------------------
Wed Aug 29 10:33:58 UTC 2018 - tchvatal@suse.com
- Add license
- Run the tests in a way to work on 42.3
-------------------------------------------------------------------
Mon Apr 10 08:30:24 UTC 2017 - alarrosa@suse.com
- Update for singlespec
- Add do-not-install-test_cookies.diff so test_cookies.py is not
installed in the system.
-------------------------------------------------------------------
Tue Feb 21 13:22:24 UTC 2017 - jengelh@inai.de
- Trim long description
-------------------------------------------------------------------
Mon Feb 20 10:13:44 UTC 2017 - alarrosa@suse.com
- Use py.test in %check to fix "setup.py test" not working
with python 3.6
-------------------------------------------------------------------
Thu Jan 19 14:35:13 UTC 2017 - alarrosa@suse.com
- Initial release

90
python-cookies.spec Normal file
View File

@ -0,0 +1,90 @@
#
# spec file for package python-cookies
#
# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%{?sle15_python_module_pythons}
Name: python-cookies
Version: 2.2.1
Release: 0
Summary: Friendlier RFC 6265-compliant cookie parser/renderer
License: MIT
Group: Development/Languages/Python
URL: https://gitlab.com/sashahart/cookies
Source: https://files.pythonhosted.org/packages/source/c/cookies/cookies-%{version}.tar.gz
Source1: https://raw.githubusercontent.com/sashahart/cookies/master/LICENSE
# PATCH-FIX-OPENSUSE do-not-install-test_cookies.diff -- Do not install test files
Patch0: do-not-install-test_cookies.diff
Patch1: python37.patch
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module setuptools}
BuildRequires: python-rpm-macros
BuildArch: noarch
%python_subpackages
%description
cookies.py is a Python module for working with HTTP cookies: parsing and
rendering 'Cookie:' request headers and 'Set-Cookie:' response headers,
and exposing a convenient API for creating and modifying cookies. It can be
used as a replacement of Python's Cookie.py (aka http.cookies).
* Rendering according to RFC 6265. It uses URL encoding to represent
non-ASCII by default, like many other languages' libraries.
* Liberal parsing, incorporating many complaints about Cookie.py
barfing on common cookie formats which can be reliably parsed
* Documented code, with chapter and verse from RFCs
* A test suite with 100%% test coverage
* Unlike Cookie.py, it doesn't lock all implementation inside its own
classes. You can suppress minor parse exceptions with parameters
rather than subclass wrappers. You can plug in your own parsers,
renderers and validators for new or existing cookie attributes. You
can render the data out in a dict. You can use the underlying
imperative API or even lift the parser's regexps for your own
parser or project.
While this is intended to be a good module for handling cookies, it does not
even try to do any of the following:
* Backward compatibility with Cookie.py
* Implementation of RFC 2109 or 2965
* Handle every conceivable output from legacy applications
* Provide a means to store pickled Python objects in cookie values
This does not compete with the cookielib (http.cookiejar) module in the Python
standard library.
%prep
%setup -q -n cookies-%{version}
%autopatch -p1
cp %{SOURCE1} .
%build
%python_build
%install
%python_install
%check
%python_expand py.test-%{$python_version} test_cookies.py
%files %{python_files}
%license LICENSE
%doc README
%{python_sitelib}/*
%changelog

225
python37.patch Normal file
View File

@ -0,0 +1,225 @@
Index: cookies-2.2.1/cookies.py
===================================================================
--- cookies-2.2.1.orig/cookies.py
+++ cookies-2.2.1/cookies.py
@@ -132,7 +132,7 @@ class Definitions(object):
# attribute and extract it appropriately.
# As compared with the RFC production grammar, it is must more liberal with
# space characters, in order not to break on data made by barbarians.
- SET_COOKIE_HEADER = """(?x) # Verbose mode
+ SET_COOKIE_HEADER = r"""(?x) # Verbose mode
^(?:Set-Cookie:[ ]*)?
(?P<name>[{name}:]+)
[ ]*=[ ]*
@@ -203,7 +203,7 @@ class Definitions(object):
# Here is the overall date format; ~99% of cases fold into one generalized
# syntax like RFC 1123, and many of the rest use asctime-like formats.
# (see test_date_formats for a full exegesis)
- DATE = """(?ix) # Case-insensitive mode, verbose mode
+ _DATE = """
(?:
(?P<weekday>(?:{wdy}|{weekday}),[ ])?
(?P<day>{day})
@@ -230,11 +230,17 @@ class Definitions(object):
(?P<year2>\d\d\d\d)
(?:[ ]GMT)? # GMT (Amazon)
)
- """
- DATE = DATE.format(wdy=WEEKDAY_SHORT, weekday=WEEKDAY_LONG,
- day=DAY_OF_MONTH, mon=MONTH_SHORT, month=MONTH_LONG)
+ """.format(wdy=WEEKDAY_SHORT, weekday=WEEKDAY_LONG,
+ day=DAY_OF_MONTH, mon=MONTH_SHORT, month=MONTH_LONG)
+
+ # Starting in Python 3.6, embedding a regex that starts with "(?ix)" in
+ # the middle of another regex produces a warning (and will stop working
+ # altogether in some future Python version). We thus create two variables
+ # here: _DATE is for embedding inside other regexes (which must themselves
+ # begin with "(?ix)"), DATE is for standalone matching.
+ DATE = '(?ix)' + _DATE
- EXPIRES_AV = "Expires=(?P<expires>%s)" % DATE
+ EXPIRES_AV = "Expires=(?P<expires>%s)" % _DATE
# Now we're ready to define a regexp which can match any number of attrs
# in the variable portion of the Set-Cookie header (like the unnamed latter
@@ -263,7 +269,7 @@ class Definitions(object):
path=PATH_AV, stuff=EXTENSION_AV)
# For request data ("Cookie: ") parsing, with finditer cf. RFC 6265 4.2.1
- COOKIE = """(?x) # Verbose mode
+ COOKIE = r"""(?x) # Verbose mode
(?: # Either something close to valid...
# Match starts at start of string, or at separator.
@@ -306,13 +312,13 @@ class Definitions(object):
""".format(name=COOKIE_NAME, value=COOKIE_OCTET)
# Precompile externally useful definitions into re objects.
- COOKIE_NAME_RE = re.compile("^([%s:]+)\Z" % COOKIE_NAME)
+ COOKIE_NAME_RE = re.compile(r"^([%s:]+)\Z" % COOKIE_NAME)
COOKIE_RE = re.compile(COOKIE)
SET_COOKIE_HEADER_RE = re.compile(SET_COOKIE_HEADER)
ATTR_RE = re.compile(ATTR)
DATE_RE = re.compile(DATE)
DOMAIN_RE = re.compile(DOMAIN)
- PATH_RE = re.compile('^([%s]+)\Z' % EXTENSION_AV)
+ PATH_RE = re.compile(r'^([%s]+)\Z' % EXTENSION_AV)
EOL = re.compile("(?:\r\n|\n)")
@@ -965,7 +971,7 @@ class Cookie(object):
'path': valid_path,
'max_age': valid_max_age,
'comment': valid_value,
- 'version': lambda number: re.match("^\d+\Z", str(number)),
+ 'version': lambda number: re.match(r"^\d+\Z", str(number)),
'secure': lambda item: item is True or item is False,
'httponly': lambda item: item is True or item is False,
}
Index: cookies-2.2.1/test_cookies.py
===================================================================
--- cookies-2.2.1.orig/test_cookies.py
+++ cookies-2.2.1/test_cookies.py
@@ -35,19 +35,19 @@ class RFC1034:
digit = "[0-9]"
letter = "[A-Za-z]"
let_dig = "[0-9A-Za-z]"
- let_dig_hyp = "[0-9A-Za-z\-]"
+ let_dig_hyp = r"[0-9A-Za-z\-]"
assert "\\" in let_dig_hyp
ldh_str = "%s+" % let_dig_hyp
label = "(?:%s|%s|%s)" % (
letter,
letter + let_dig,
letter + ldh_str + let_dig)
- subdomain = "(?:%s\.)*(?:%s)" % (label, label)
+ subdomain = r"(?:%s\.)*(?:%s)" % (label, label)
domain = "( |%s)" % (subdomain)
def test_sanity(self):
"Basic smoke tests that definitions transcribed OK"
- match = re.compile("^%s\Z" % self.domain).match
+ match = re.compile(r"^%s\Z" % self.domain).match
assert match("A.ISI.EDU")
assert match("XX.LCS.MIT.EDU")
assert match("SRI-NIC.ARPA")
@@ -74,12 +74,12 @@ class RFC1123:
# n.b.: there are length limits in the real thing
label = "{let_dig}(?:(?:{let_dig_hyp}+)?{let_dig})?".format(
let_dig=RFC1034.let_dig, let_dig_hyp=RFC1034.let_dig_hyp)
- subdomain = "(?:%s\.)*(?:%s)" % (label, label)
+ subdomain = r"(?:%s\.)*(?:%s)" % (label, label)
domain = "( |%s)" % (subdomain)
def test_sanity(self):
"Basic smoke tests that definitions transcribed OK"
- match = re.compile("^%s\Z" % self.domain).match
+ match = re.compile(r"^%s\Z" % self.domain).match
assert match("A.ISI.EDU")
assert match("XX.LCS.MIT.EDU")
assert match("SRI-NIC.ARPA")
@@ -241,7 +241,7 @@ class TestDefinitions(object):
; whitespace DQUOTE, comma, semicolon,
; and backslash
"""
- match = re.compile("^[%s]+\Z" % Definitions.COOKIE_OCTET).match
+ match = re.compile(r"^[%s]+\Z" % Definitions.COOKIE_OCTET).match
for c in RFC5234.CTL:
assert not match(c)
assert not match("a%sb" % c)
@@ -331,7 +331,7 @@ class TestDefinitions(object):
('frob', 'laz', '')]
def assert_correct(s):
- #naive = re.findall(" *([^;]+)=([^;]+) *(?:;|\Z)", s)
+ #naive = re.findall(r" *([^;]+)=([^;]+) *(?:;|\Z)", s)
result = regex.findall(s)
assert result == correct
# normal-looking case should work normally
@@ -390,7 +390,7 @@ class TestDefinitions(object):
extension_av_explicit = "".join(sorted(
set(RFC5234.CHAR) - set(RFC5234.CTL + ";")))
# ... that should turn out to be the same as Definitions.EXTENSION_AV
- match = re.compile("^([%s]+)\Z" % Definitions.EXTENSION_AV).match
+ match = re.compile(r"^([%s]+)\Z" % Definitions.EXTENSION_AV).match
# Verify I didn't mess up on escaping here first
assert match(r']')
assert match(r'[')
@@ -411,7 +411,7 @@ class TestDefinitions(object):
def test_max_age_av(self):
"Smoke test Definitions.MAX_AGE_AV"
# Not a lot to this, it's just digits
- match = re.compile("^%s\Z" % Definitions.MAX_AGE_AV).match
+ match = re.compile(r"^%s\Z" % Definitions.MAX_AGE_AV).match
assert not match("")
assert not match("Whiskers")
assert not match("Max-Headroom=992")
@@ -424,7 +424,7 @@ class TestDefinitions(object):
def test_label(self, check_unicode=False):
"Test label, as used in Domain attribute"
- match = re.compile("^(%s)\Z" % Definitions.LABEL).match
+ match = re.compile(r"^(%s)\Z" % Definitions.LABEL).match
for i in range(0, 10):
assert match(str(i))
assert not match(".")
@@ -459,7 +459,7 @@ class TestDefinitions(object):
assert match(domain)
# Now same tests through DOMAIN_AV
- match = re.compile("^%s\Z" % Definitions.DOMAIN_AV).match
+ match = re.compile(r"^%s\Z" % Definitions.DOMAIN_AV).match
for domain in bad_domains:
assert not match("Domain=%s" % domain)
for domain in good_domains:
@@ -487,7 +487,7 @@ class TestDefinitions(object):
for path in good_paths:
assert match(path)
- match = re.compile("^%s\Z" % Definitions.PATH_AV).match
+ match = re.compile(r"^%s\Z" % Definitions.PATH_AV).match
for path in bad_paths:
assert not match("Path=%s" % path)
for path in good_paths:
@@ -575,7 +575,7 @@ class TestDefinitions(object):
# dependencies, and odds are good that other implementations are loose.
# so this parser is also loose. "liberal in what you accept,
# conservative in what you produce"
- match = re.compile("^%s\Z" % Definitions.EXPIRES_AV).match
+ match = re.compile(r"^%s\Z" % Definitions.EXPIRES_AV, flags=re.I | re.X).match
assert not match("")
assert not match("Expires=")
@@ -610,7 +610,7 @@ class TestDefinitions(object):
If this works, then ATTR should work
"""
- match = re.compile("^[%s]+\Z" % Definitions.EXTENSION_AV).match
+ match = re.compile(r"^[%s]+\Z" % Definitions.EXTENSION_AV).match
assert match("Expires=Sun, 06 Nov 1994 08:49:37 GMT")
assert match("Expires=Sunday, 06-Nov-94 08:49:37 GMT")
assert match("Expires=Sun Nov 6 08:49:37 1994")
@@ -2225,7 +2225,10 @@ def test_encoding_assumptions(check_unic
else:
assert cookie_value_re.match(quoted)
- assert set(dont_quote) == set("!#$%&'()*+/:<=>?@[]^`{|}~")
+ if sys.version_info < (3, 7, 0):
+ assert set(dont_quote) == set("!#$%&'()*+/:<=>?@[]^`{|}~")
+ else:
+ assert set(dont_quote) == set("!#$%&'()*+/:<=>?@[]^`{|}")
# From 128 on urllib.quote will not work on a unichr() return value.
# We'll want to encode utf-8 values into ASCII, then do the quoting.
@@ -2257,7 +2260,10 @@ def test_encoding_assumptions(check_unic
else:
assert extension_av_re.match(quoted)
- assert set(dont_quote) == set(' !"#$%&\'()*+,/:<=>?@[\\]^`{|}~')
+ if sys.version_info < (3, 7, 0):
+ assert set(dont_quote) == set(' !"#$%&\'()*+,/:<=>?@[\\]^`{|}~')
+ else:
+ assert set(dont_quote) == set(' !"#$%&\'()*+,/:<=>?@[\\]^`{|}')
test_encode_cookie_value = _simple_test(encode_cookie_value,