389322
diff --git a/setuptools/package_index.py b/setuptools/package_index.py
389322
index b6407be..bdcf4a6 100755
389322
--- a/setuptools/package_index.py
389322
+++ b/setuptools/package_index.py
389322
@@ -212,7 +212,7 @@ def unique_values(func):
389322
     return wrapper
389322
 
389322
 
389322
-REL = re.compile(r"""<([^>]*\srel\s*=\s*['"]?([^'">]+)[^>]*)>""", re.I)
389322
+REL = re.compile(r"""<([^>]*\srel\s{0,10}=\s{0,10}['"]?([^'" >]+)[^>]*)>""", re.I)
389322
 # this line is here to fix emacs' cruddy broken syntax highlighting
389322
 
389322
 
389322
diff --git a/setuptools/tests/test_packageindex.py b/setuptools/tests/test_packageindex.py
389322
index 63b9294..49bd819 100644
389322
--- a/setuptools/tests/test_packageindex.py
389322
+++ b/setuptools/tests/test_packageindex.py
389322
@@ -223,6 +223,12 @@ class TestPackageIndex:
389322
             assert dists[0].version == ''
389322
             assert dists[1].version == vc
389322
 
389322
+    def test_REL_DoS(self):
389322
+        """
389322
+        REL should not hang on a contrived attack string.
389322
+        """
389322
+        setuptools.package_index.REL.search('< rel=' + ' ' * 2**12)
389322
+
389322
 
389322
 class TestContentCheckers:
389322
     def test_md5(self):