9bff81
diff --git a/setuptools/package_index.py b/setuptools/package_index.py
9bff81
index 123e958..a90b810 100644
9bff81
--- a/setuptools/package_index.py
9bff81
+++ b/setuptools/package_index.py
9bff81
@@ -215,7 +215,7 @@ def unique_values(func):
9bff81
     return wrapper
9bff81
 
9bff81
 
9bff81
-REL = re.compile(r"""<([^>]*\srel\s*=\s*['"]?([^'">]+)[^>]*)>""", re.I)
9bff81
+REL = re.compile(r"""<([^>]*\srel\s{0,10}=\s{0,10}['"]?([^'" >]+)[^>]*)>""", re.I)
9bff81
 # this line is here to fix emacs' cruddy broken syntax highlighting
9bff81
 
9bff81
 
9bff81
diff --git a/setuptools/tests/test_packageindex.py b/setuptools/tests/test_packageindex.py
9bff81
index 8e9435e..bc1e373 100644
9bff81
--- a/setuptools/tests/test_packageindex.py
9bff81
+++ b/setuptools/tests/test_packageindex.py
9bff81
@@ -308,3 +308,10 @@ class TestPyPIConfig:
9bff81
         cred = cfg.creds_by_repository['https://pypi.org']
9bff81
         assert cred.username == 'jaraco'
9bff81
         assert cred.password == 'pity%'
9bff81
+
9bff81
+@pytest.mark.timeout(1)
9bff81
+def test_REL_DoS():
9bff81
+    """
9bff81
+    REL should not hang on a contrived attack string.
9bff81
+    """
9bff81
+    setuptools.package_index.REL.search('< rel=' + ' ' * 2**12)