Skip to content

Commit 5791343

Browse files
committed
Add test capturing failed expectation. Ref #3659.
1 parent 1f97905 commit 5791343

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

setup.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ testing =
7171
pip_run>=8.8
7272
ini2toml[lite]>=0.9
7373
tomli-w>=1.0.0
74+
pytest-timeout
7475

7576
testing-integration =
7677
pytest

setuptools/package_index.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
"""PyPI and direct package downloading"""
1+
"""PyPI and direct package downloading."""
2+
23
import sys
34
import os
45
import re
@@ -217,6 +218,9 @@ def wrapper(*args, **kwargs):
217218

218219

219220
REL = re.compile(r"""<([^>]*\srel\s*=\s*['"]?([^'">]+)[^>]*)>""", re.I)
221+
"""
222+
Regex for an HTML tag with 'rel="val"' attributes.
223+
"""
220224

221225

222226
@unique_values

setuptools/tests/test_packageindex.py

+9
Original file line numberDiff line numberDiff line change
@@ -305,3 +305,12 @@ def test_percent_in_password(self, temp_home):
305305
cred = cfg.creds_by_repository['https://pypi.org']
306306
assert cred.username == 'jaraco'
307307
assert cred.password == 'pity%'
308+
309+
310+
@pytest.mark.xfail(reason="#3659")
311+
@pytest.mark.timeout(1)
312+
def test_REL_DoS():
313+
"""
314+
REL should not hang on a contrived attack string.
315+
"""
316+
setuptools.package_index.REL.search('< rel=' + ' ' * 2**12)

0 commit comments

Comments
 (0)