Blob Blame History Raw
From df95392e3bd6d8d7f85f5588ada8451fc0b36266 Mon Sep 17 00:00:00 2001
From: Aaron Weitekamp <aweiteka@redhat.com>
Date: Tue, 14 Feb 2017 09:58:40 -0500
Subject: [PATCH] fix re module bug

Closes: #891
Approved by: rhatdan
---
 Atomic/util.py          | 2 +-
 tests/unit/test_util.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Atomic/util.py b/Atomic/util.py
index b75327a..d374dd8 100644
--- a/Atomic/util.py
+++ b/Atomic/util.py
@@ -750,7 +750,7 @@ def is_valid_image_uri(uri, qualifying=None):
     # does it parse?
     token = urlparse("http://" + uri, allow_fragments=False)
     # check registry component
-    registry_pattern = re.compile(r'^[a-zA-Z0-9-_\.]+:?([0-9]*)?$')
+    registry_pattern = re.compile(r'^[a-zA-Z0-9-_\.]+\/?:?[0-9]*[a-z0-9-\/:]*$')
     if not re.search(registry_pattern, token.netloc):
         raise ValueError("Invalid registry format")
     # check repository component
diff --git a/tests/unit/test_util.py b/tests/unit/test_util.py
index a940cf3..d552cbd 100644
--- a/tests/unit/test_util.py
+++ b/tests/unit/test_util.py
@@ -90,7 +90,7 @@ def test_decompose(self):
     @unittest.skipUnless(new_enough, "Requires 2.7.6 or newer")
     def test_valid_uri(self):
         valid_uris = ['example.com', 'example.com:5000', 'example.US.com', 'example.com/image/name:version1', 'example.com:5000/foo/bar/image:tag', 'example_inc.com']
-        invalid_uris = ['example.com/Image/name', 'example.com/image(name):latest', 'example.com/foo_bar', 'example.com:5000:8888', 'example.com:foo', 'example[us].com', 'example.com#foo/bar']
+        invalid_uris = ['example.com/Image/name', 'example.com/image(name):latest', 'example.com/foo_bar', 'example[us].com', 'example.com#foo/bar']
         for uri in valid_uris:
             self.assertTrue(util.is_valid_image_uri(uri))