Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-mechanize for openSUSE:Factory checked in at 2026-11-30 14:27:33 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-mechanize (Old) and /work/SRC/openSUSE:Factory/.python-mechanize.new.1340718 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-mechanize" Mon Nov 30 14:27:33 2026 rev:37 rq:1401501 version:0.4.11 Changes: -------- --- /work/SRC/openSUSE:Factory/python-mechanize/python-mechanize.changes 2025-08-12 17:04:56.992198779 +0200 +++ /work/SRC/openSUSE:Factory/.python-mechanize.new.1340718/python-mechanize.changes 2026-11-30 14:30:26.819167620 +0100 @@ -1,0 +2,13 @@ +Sun Nov 29 21:34:00 UTC 2026 - Dirk Müller <[email protected]> + +- update to 0.4.11: + * Security: Do not send Basic auth credentials to redirect + targets, and drop caller-set Authorization and Cookie headers + when a redirect changes the scheme, host or port + * Accept zero-padded gzip responses + * Fix reading gzip extra-field lengths on Python 3 + * Append GET form parameters before the URL fragment + * Reload robots rules when the request scheme changes +- drop 0001-Fix-CookieTests-following-fix-for-CPython-130631.patch (upstream) + +------------------------------------------------------------------- Old: ---- 0001-Fix-CookieTests-following-fix-for-CPython-130631.patch mechanize-0.4.10.tar.gz New: ---- mechanize-0.4.11.tar.gz ----------(Old B)---------- Old: * Reload robots rules when the request scheme changes - drop 0001-Fix-CookieTests-following-fix-for-CPython-130631.patch (upstream) ----------(Old E)---------- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-mechanize.spec ++++++ --- /var/tmp/diff_new_pack.ZekX6h/_old 2026-11-30 14:30:28.270228576 +0100 +++ /var/tmp/diff_new_pack.ZekX6h/_new 2026-11-30 14:30:28.272228660 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-mechanize # -# Copyright (c) 2025 SUSE LLC +# Copyright (c) 2026 SUSE LLC and contributors # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,23 +19,21 @@ %define modname mechanize %{?sle15_python_module_pythons} Name: python-mechanize -Version: 0.4.10 +Version: 0.4.11 Release: 0 Summary: Stateful programmatic web browsing License: BSD-3-Clause AND (BSD-3-Clause OR ZPL-2.1) URL: https://github.com/python-mechanize/mechanize Source: https://files.pythonhosted.org/packages/source/m/mechanize/%{modname}-%{version}.tar.gz -# PATCH-FIX-UPSTREAM https://github.com/python-mechanize/mechanize/pull/102 -Patch1: 0001-Fix-CookieTests-following-fix-for-CPython-130631.patch BuildRequires: %{python_module Twisted} -BuildRequires: %{python_module html5lib} +BuildRequires: %{python_module html5lib >= 0.999999999} BuildRequires: %{python_module pip} BuildRequires: %{python_module setuptools} BuildRequires: %{python_module wheel} BuildRequires: %{python_module zope.interface} BuildRequires: fdupes BuildRequires: python-rpm-macros -Requires: python-html5lib +Requires: python-html5lib >= 0.999999999 BuildArch: noarch %python_subpackages ++++++ mechanize-0.4.10.tar.gz -> mechanize-0.4.11.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mechanize-0.4.10/ChangeLog new/mechanize-0.4.11/ChangeLog --- old/mechanize-0.4.10/ChangeLog 2024-04-26 03:25:15.000000000 +0200 +++ new/mechanize-0.4.11/ChangeLog 2026-11-22 03:17:04.106154000 +0100 @@ -1,6 +1,16 @@ This isn't really in proper GNU ChangeLog format, it just happens to look that way. +2026-11-22 Kovid Goyal + * 0.4.11 release + * Security: Do not send Basic auth credentials to redirect targets, and drop + caller-set Authorization and Cookie headers when a redirect changes the + scheme, host or port + * Accept zero-padded gzip responses + * Fix reading gzip extra-field lengths on Python 3 + * Append GET form parameters before the URL fragment + * Reload robots rules when the request scheme changes + 2024-04-26 Kovid Goyal * 0.4.10 release * Fix overly long MIME multipart separator on 64 bit systems diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mechanize-0.4.10/PKG-INFO new/mechanize-0.4.11/PKG-INFO --- old/mechanize-0.4.10/PKG-INFO 2024-04-26 03:25:53.879448700 +0200 +++ new/mechanize-0.4.11/PKG-INFO 2026-11-22 03:17:17.437877200 +0100 @@ -1,6 +1,6 @@ -Metadata-Version: 2.1 +Metadata-Version: 2.4 Name: mechanize -Version: 0.4.10 +Version: 0.4.11 Summary: Stateful, programmatic web browsing Home-page: https://github.com/python-mechanize/mechanize Author: Kovid Goyal @@ -44,6 +44,7 @@ Provides-Extra: binarytest Requires-Dist: lxml; extra == "binarytest" Requires-Dist: html5-parser; extra == "binarytest" +Dynamic: license-file mechanize - Automate interaction with HTTP web servers ########################################################## diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mechanize-0.4.10/mechanize/_gzip.py new/mechanize-0.4.11/mechanize/_gzip.py --- old/mechanize-0.4.10/mechanize/_gzip.py 2021-08-01 06:46:45.000000000 +0200 +++ new/mechanize-0.4.11/mechanize/_gzip.py 2026-11-16 06:37:46.470735000 +0100 @@ -100,10 +100,19 @@ tail = self.__decoder.unused_data if len(tail) < 8: tail += read_amt(self.__fp, 8 - len(tail)) - # ignore any extra bytes after end of compressed stream - self.__fp.read() + # Allow zero padding after the trailer, as the gzip module + # does. Other data, such as further gzip members, is not + # supported, so fail rather than silently truncate. + extra = tail[8:] + while True: + if extra.strip(b'\0'): + raise ValueError( + 'unsupported trailing data after gzip stream') + extra = self.__fp.read(DEFAULT_BUFFER_SIZE) + if not extra: + break # check CRC, ignore size mismatch - crc, size = struct.unpack(b'<LL', tail) + crc, size = struct.unpack(b'<LL', tail[:8]) if (crc & CRC_MASK) != (self.__crc & CRC_MASK): raise ValueError( 'gzip stream is corrupted, CRC does not match') @@ -158,8 +167,7 @@ prefix[2]) flag = ord(prefix[3:4]) if flag & 4: # extra - extra_amt = read_amt(zipped_file, 2) - extra_amt = ord(extra_amt[0]) + 256 * ord(extra_amt[1]) + extra_amt = struct.unpack(b'<H', read_amt(zipped_file, 2))[0] if extra_amt: read_amt(zipped_file, extra_amt) if flag & 8: # filename diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mechanize-0.4.10/mechanize/_http.py new/mechanize-0.4.11/mechanize/_http.py --- old/mechanize-0.4.10/mechanize/_http.py 2021-12-19 17:31:57.000000000 +0100 +++ new/mechanize-0.4.11/mechanize/_http.py 2026-10-29 04:12:12.379822300 +0100 @@ -141,6 +141,7 @@ self.rfp_class = rfp_class self.rfp = None self._host = None + self._scheme = None def __copy__(self): return self.__class__(self.rfp_class) @@ -164,7 +165,7 @@ origin_req.get_host() == host): return request - if host != self._host: + if host != self._host or scheme != self._scheme: self.rfp = self.rfp_class() try: self.rfp.set_opener(self.parent) @@ -175,6 +176,7 @@ self.rfp.set_timeout(request.timeout) self.rfp.read() self._host = host + self._scheme = scheme ua = request.get_header("User-agent", "") if self.rfp.can_fetch(ua, request.get_full_url()): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mechanize-0.4.10/mechanize/_request.py new/mechanize-0.4.11/mechanize/_request.py --- old/mechanize-0.4.10/mechanize/_request.py 2019-06-03 13:57:53.000000000 +0200 +++ new/mechanize-0.4.11/mechanize/_request.py 2026-10-29 04:28:15.037369000 +0100 @@ -69,7 +69,9 @@ data = urlencode(data) data = data or None if data and method == 'GET': + url, separator, fragment = url.partition('#') url += ('&' if '?' in url else '?') + data + url += separator + fragment data = None _urllib2_fork.Request.__init__(self, url, data, headers, method=method) self.selector = None diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mechanize-0.4.10/mechanize/_urllib2_fork.py new/mechanize-0.4.11/mechanize/_urllib2_fork.py --- old/mechanize-0.4.10/mechanize/_urllib2_fork.py 2023-10-04 02:37:42.000000000 +0200 +++ new/mechanize-0.4.11/mechanize/_urllib2_fork.py 2026-11-22 03:15:03.191960000 +0100 @@ -564,6 +564,26 @@ raise response +_CROSS_ORIGIN_STRIP_HEADERS = frozenset(('authorization', 'cookie')) +_DEFAULT_PORTS = {'http': 80, 'https': 443} + + +def _url_origin(url): + parts = urlsplit(url) + scheme = (parts.scheme or '').lower() + try: + port = parts.port + except ValueError: + port = parts.netloc.rpartition(':')[2] + if port is None: + port = _DEFAULT_PORTS.get(scheme) + return scheme, parts.hostname, port + + +def _same_origin(url_a, url_b): + return _url_origin(url_a) == _url_origin(url_b) + + class HTTPRedirectHandler(BaseHandler): # maximum number of redirections to any single URL # this is needed because of the state that cookies introduce @@ -610,9 +630,16 @@ # the same. # TODO: really refresh redirections should be visiting; tricky to # fix + headers = req.headers + if not _same_origin(req.get_full_url(), newurl): + # Do not leak credentials set by the caller to a different + # origin + headers = OrderedDict( + (k, v) for k, v in iteritems(req.headers) + if k.lower() not in _CROSS_ORIGIN_STRIP_HEADERS) new = Request( newurl, - headers=req.headers, + headers=headers, origin_req_host=req.get_origin_req_host(), unverifiable=True, visit=False, method=m if code in (307, 308) else None, @@ -922,7 +949,9 @@ if req.get_header(self.auth_header, None) == auth: return None newreq = copy.copy(req) - newreq.add_header(self.auth_header, auth) + # Use an unredirected header so that the credentials are not + # sent along to whatever URL a redirect points at + newreq.add_unredirected_header(self.auth_header, auth) newreq.visit = False return self.parent.open(newreq) else: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mechanize-0.4.10/mechanize/_version.py new/mechanize-0.4.11/mechanize/_version.py --- old/mechanize-0.4.10/mechanize/_version.py 2024-04-26 03:25:15.000000000 +0200 +++ new/mechanize-0.4.11/mechanize/_version.py 2026-11-22 03:17:04.106154000 +0100 @@ -1,3 +1,3 @@ -"0.4.10" -string_version = "0.4.10" -__version__ = (0, 4, 10, None, None) +"0.4.11" +string_version = "0.4.11" +__version__ = (0, 4, 11, None, None) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mechanize-0.4.10/mechanize.egg-info/PKG-INFO new/mechanize-0.4.11/mechanize.egg-info/PKG-INFO --- old/mechanize-0.4.10/mechanize.egg-info/PKG-INFO 2024-04-26 03:25:53.000000000 +0200 +++ new/mechanize-0.4.11/mechanize.egg-info/PKG-INFO 2026-11-22 03:17:17.397283800 +0100 @@ -1,6 +1,6 @@ -Metadata-Version: 2.1 +Metadata-Version: 2.4 Name: mechanize -Version: 0.4.10 +Version: 0.4.11 Summary: Stateful, programmatic web browsing Home-page: https://github.com/python-mechanize/mechanize Author: Kovid Goyal @@ -44,6 +44,7 @@ Provides-Extra: binarytest Requires-Dist: lxml; extra == "binarytest" Requires-Dist: html5-parser; extra == "binarytest" +Dynamic: license-file mechanize - Automate interaction with HTTP web servers ########################################################## diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mechanize-0.4.10/test/test_browser.py new/mechanize-0.4.11/test/test_browser.py --- old/mechanize-0.4.10/test/test_browser.py 2019-12-22 04:27:48.000000000 +0100 +++ new/mechanize-0.4.11/test/test_browser.py 2026-11-16 06:37:46.470735000 +0100 @@ -2,8 +2,10 @@ """Tests for mechanize.Browser.""" import copy +import gzip import os import re +import struct from io import BytesIO from unittest import TestCase @@ -770,6 +772,83 @@ self.assertFalse(h.getheaders('content-encoding')) self.assertFalse(h.getheaders('content-length')) + def test_gzip_extra_field(self): + data = b'compressed response with an optional header' + compressed = b''.join(compress_readable_output(BytesIO(data))) + for size in (0, 4, 260): + # RFC 1952 stores XLEN as a little-endian 16-bit integer. + extra = b'XY' + struct.pack('<H', size - 4) + b'x' * (size - 4) if size else b'' + encoded = (compressed[:3] + b'\x04' + compressed[4:10] + + struct.pack('<H', len(extra)) + extra + compressed[10:]) + with gzip.GzipFile(fileobj=BytesIO(encoded)) as decoded: + self.assertEqual(decoded.read(), data) + response = MockResponse('https://example.com/', data=encoded, + info={'Content-Encoding': 'gzip'}) + response = HTTPGzipProcessor().https_response( + mechanize.Request(response.geturl()), response) + self.assertEqual(response.read(), data) + + def test_gzip_zero_padding(self): + class ShortReads(BytesIO): + def read(self, size=-1): + return BytesIO.read(self, min(size, 7) if size >= 0 else size) + + for data in (b'', b'compressed response with trailing padding'): + output = BytesIO() + with gzip.GzipFile(fileobj=output, mode='wb') as writer: + writer.write(data) + for padding in (0, 1, 2048): + encoded = output.getvalue() + b'\0' * padding + for stream in (BytesIO, ShortReads): + response = MockResponse('https://example.com/', + info={'Content-Encoding': 'gzip'}) + response.fp = stream(encoded) + response = HTTPGzipProcessor().https_response( + mechanize.Request(response.geturl()), response) + self.assertEqual(response.read(3) + response.read(), data) + self.assertEqual(response.read(), b'') + + def test_gzip_padding_does_not_hide_bad_crc(self): + encoded = b''.join(compress_readable_output(BytesIO(b'payload'))) + encoded = encoded[:-8] + b'\0' * 4 + encoded[-4:] + b'\0' + response = MockResponse('https://example.com/', data=encoded, + info={'Content-Encoding': 'gzip'}) + response = HTTPGzipProcessor().https_response( + mechanize.Request(response.geturl()), response) + with self.assertRaises(ValueError): + response.read() + + def test_gzip_nonzero_trailing_data(self): + def gz(data): + return b''.join(compress_readable_output(BytesIO(data))) + + class ShortReads(BytesIO): + def read(self, size=-1): + return BytesIO.read(self, min(size, 7) if size >= 0 else size) + + for encoded in ( + gz(b'first') + gz(b'second'), # multiple members + gz(b'payload') + b'garbage', + gz(b'payload') + b'\0' * 2048 + b'x', # beyond first read + ): + for stream in (BytesIO, ShortReads): + response = MockResponse('https://example.com/', + info={'Content-Encoding': 'gzip'}) + response.fp = stream(encoded) + response = HTTPGzipProcessor().https_response( + mechanize.Request(response.geturl()), response) + with self.assertRaises(ValueError): + response.read() + + def test_gzip_truncated_trailer(self): + encoded = b''.join(compress_readable_output(BytesIO(b'payload'))) + response = MockResponse('https://example.com/', data=encoded[:-1], + info={'Content-Encoding': 'gzip'}) + response = HTTPGzipProcessor().https_response( + mechanize.Request(response.geturl()), response) + with self.assertRaises(EOFError): + response.read() + class ResponseTests(TestCase): def test_set_response(self): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mechanize-0.4.10/test/test_cookies.py new/mechanize-0.4.11/test/test_cookies.py --- old/mechanize-0.4.10/test/test_cookies.py 2022-05-24 14:39:07.000000000 +0200 +++ new/mechanize-0.4.11/test/test_cookies.py 2026-10-29 04:12:12.379822300 +0100 @@ -332,9 +332,13 @@ cookie = c._cookies["www.acme.com"]['/foo/']['"spam"'] assert cookie.name == '"spam"' assert cookie.value is None - assert lwp_cookie_str(cookie) == ( + assert lwp_cookie_str(cookie) in ( + r'"spam"; path="/foo/"; domain=www.acme.com; ' + 'path_spec; discard; version=0', + # prior to fix for https://github.com/python/cpython/issues/130631: r'"spam"; path="/foo/"; domain="www.acme.com"; ' - 'path_spec; discard; version=0') + 'path_spec; discard; version=0', + ) old_str = repr(c) c.save(ignore_expires=True, ignore_discard=True) try: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mechanize-0.4.10/test/test_urllib2.py new/mechanize-0.4.11/test/test_urllib2.py --- old/mechanize-0.4.10/test/test_urllib2.py 2024-04-26 03:25:15.000000000 +0200 +++ new/mechanize-0.4.11/test/test_urllib2.py 2026-11-22 03:15:03.191960000 +0100 @@ -1247,6 +1247,26 @@ h.http_request(req) self.assertTrue(rfpc.calls == []) + def test_robots_scheme_change(self): + rfpc = MockRobotFileParserClass() + handler = mechanize.HTTPRobotRulesProcessor(rfpc) + opener = OpenerDirector() + opener.add_handler(handler) + + for scheme in ("http", "https", "http"): + rfpc.clear() + url = scheme + "://example.com/page" + handler.http_request(Request(url)) + self.assertIn(("set_url", scheme + "://example.com/robots.txt"), + rfpc.calls) + self.assertIn("read", rfpc.calls) + + # A different path on the same origin still uses cached rules. + rfpc.clear() + url = scheme + "://example.com/another-page" + handler.http_request(Request(url)) + self.assertEqual(rfpc.calls, [("can_fetch", "", url)]) + def test_redirected_robots_txt(self): # redirected robots.txt fetch shouldn't result in another attempted # robots.txt fetch to check the redirection is allowed! @@ -1516,6 +1536,75 @@ o.open("http://www.example.com/") self.assertFalse(hh.req.has_header("Cookie")) + def test_redirect_strips_credentials_cross_origin(self): + h = HTTPRedirectHandler() + o = h.parent = MockOpener() + from_url = "http://example.com/a.html" + cases = [ + ("http://example.com/b.html", True), + ("http://EXAMPLE.com:80/b.html", True), + ("http://other.example.com/b.html", False), + ("http://example.com:8080/b.html", False), + ("https://example.com/b.html", False), + ("http://example.com:bad/b.html", False), + ] + for to_url, same_origin in cases: + for code in 301, 302, 303, 307, 308: + req = Request(from_url) + req.add_header("Authorization", "Basic c2VjcmV0") + req.add_header("Cookie", "session=secret") + req.add_header("Proxy-Authorization", "Basic cHJveHk=") + req.add_header("Nonsense", "viking=withhold") + h.http_error_302(req, MockFile(), code, "Blah", + http_message({"location": to_url})) + newreq = o.req + self.assertEqual(newreq.get_full_url(), to_url) + self.assertEqual(newreq.has_header("Authorization"), + same_origin, (to_url, code)) + self.assertEqual(newreq.has_header("Cookie"), same_origin, + (to_url, code)) + self.assertTrue(newreq.has_header("Proxy-authorization")) + self.assertEqual(newreq.get_header("Nonsense"), + "viking=withhold") + + def test_basic_auth_not_sent_on_redirect(self): + # credentials from add_password() must not follow a redirect + # issued after the 401 retry + class AuthThenRedirectHandler(mechanize.BaseHandler): + def __init__(self, location): + self.location = location + self.requests = [] + + def http_open(self, req): + import copy + self.requests.append(copy.deepcopy(req)) + if req.get_host() == "a.example.com": + if not req.has_header("Authorization"): + hdr = 'WWW-Authenticate: Basic realm="r"\r\n\r\n' + code = 401 + else: + hdr = "Location: %s\r\n\r\n" % self.location + code = 302 + msg = create_response_info(BytesIO( + hdr.encode("iso-8859-1"))) + return self.parent.error( + "http", req, test_response(), code, "Blah", msg) + return test_response("", [], req.get_full_url()) + + for location in ("http://b.example.com/", + "http://a.example.com:8080/"): + hh = AuthThenRedirectHandler(location) + ah = mechanize.HTTPBasicAuthHandler() + ah.add_password("r", "http://a.example.com/", "user", "pw") + o = build_test_opener(hh, mechanize.HTTPDefaultErrorHandler(), + HTTPRedirectHandler(), ah) + o.open("http://a.example.com/") + self.assertEqual( + [r.get_full_url() for r in hh.requests], + ["http://a.example.com/", "http://a.example.com/", location]) + self.assertTrue(hh.requests[1].has_header("Authorization")) + self.assertFalse(hh.requests[2].has_header("Authorization")) + def test_proxy(self): o = OpenerDirector() ph = mechanize.ProxyHandler(dict(http="proxy.example.com:3128")) @@ -1913,6 +2002,21 @@ self.assertEqual(r.get_data(), None) self.assertEqual(r.get_full_url(), 'https://example.com?a=1') + def test_get_data_before_fragment(self): + for suffix, expected in ( + ('#section', '?a=two+words#section'), + ('?old=1#section', '?old=1&a=two+words#section'), + ('#section?question', '?a=two+words#section?question'), + ('#', '?a=two+words')): + url = 'https://example.com/path' + request = Request(url + suffix, data={'a': 'two words'}, + method='GET') + self.assertEqual(request.get_full_url(), url + expected) + self.assertEqual(request.get_selector(), + '/path' + expected.split('#', 1)[0]) + self.assertIsNone(request.get_data()) + self.assertEqual(request.get_method(), 'GET') + if __name__ == "__main__": import doctest
