diff options
Diffstat (limited to 'net-misc/streamlink/files/streamlink-6.7.2-validator.patch')
-rw-r--r-- | net-misc/streamlink/files/streamlink-6.7.2-validator.patch | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/net-misc/streamlink/files/streamlink-6.7.2-validator.patch b/net-misc/streamlink/files/streamlink-6.7.2-validator.patch new file mode 100644 index 000000000000..8dc69d62616a --- /dev/null +++ b/net-misc/streamlink/files/streamlink-6.7.2-validator.patch @@ -0,0 +1,61 @@ +https://github.com/streamlink/streamlink/pull/5932 +https://github.com/streamlink/streamlink/commit/0466622dc0bd13db972f6a00d2e2bda31ad50229 + +Quoting the PR: +""" +Since Python 3.11.9 / 3.12.3 / 3.13.0a6, urllib.parse.parse_qsl() now raises a TypeError +if the input is not a str, is truthy and can't be passed to memoryview(), like integers for example, +hence the test failure which previously just checked an invalid input to that validation schema. +""" + +From 51c13ddd45f83384cf7800a881127ad74dec3bb8 Mon Sep 17 00:00:00 2001 +From: bastimeyer <mail@bastimeyer.de> +Date: Tue, 9 Apr 2024 21:36:03 +0200 +Subject: [PATCH] plugin.api.validate: check parse_qsd() input type + +--- + src/streamlink/plugin/api/validate/_validators.py | 6 +++++- + tests/test_api_validate.py | 11 +++++++++-- + 2 files changed, 14 insertions(+), 3 deletions(-) + +diff --git a/src/streamlink/plugin/api/validate/_validators.py b/src/streamlink/plugin/api/validate/_validators.py +index 69135b74919..e99d305733f 100644 +--- a/src/streamlink/plugin/api/validate/_validators.py ++++ b/src/streamlink/plugin/api/validate/_validators.py +@@ -651,4 +651,8 @@ def validator_parse_qsd(*args, **kwargs) -> TransformSchema: + :raise ValidationError: On parsing error + """ + +- return TransformSchema(_parse_qsd, *args, **kwargs, exception=ValidationError, schema=None) ++ def parser(*_args, **_kwargs): ++ validate(AnySchema(str, bytes), _args[0]) ++ return _parse_qsd(*_args, **_kwargs, exception=ValidationError, schema=None) ++ ++ return TransformSchema(parser, *args, **kwargs) +diff --git a/tests/test_api_validate.py b/tests/test_api_validate.py +index ceff9bc1dde..c328116d27b 100644 +--- a/tests/test_api_validate.py ++++ b/tests/test_api_validate.py +@@ -1343,13 +1343,20 @@ def test_success(self): + validate.parse_qsd(), + "foo=bar&foo=baz&qux=quux", + ) == {"foo": "baz", "qux": "quux"} ++ assert validate.validate( ++ validate.parse_qsd(), ++ b"foo=bar&foo=baz&qux=quux", ++ ) == {b"foo": b"baz", b"qux": b"quux"} + + def test_failure(self): + with pytest.raises(ValidationError) as cm: + validate.validate(validate.parse_qsd(), 123) + assert_validationerror(cm.value, """ +- ValidationError: +- Unable to parse query string: 'int' object has no attribute 'decode' (123) ++ ValidationError(AnySchema): ++ ValidationError(type): ++ Type of 123 should be str, but is int ++ ValidationError(type): ++ Type of 123 should be bytes, but is int + """) + + |