qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject [18/41] qpid-proton git commit: PROTON-1853: [Python] Fix Url parsing to cope with '://' in path
Date Wed, 04 Jul 2018 15:57:50 GMT
PROTON-1853: [Python] Fix Url parsing to cope with '://' in path


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/ccfd19ce
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/ccfd19ce
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/ccfd19ce

Branch: refs/heads/go1
Commit: ccfd19ce2a296482e1b8f9f378c8f90050048e76
Parents: 67d4d74
Author: Andrew Stitcher <astitcher@apache.org>
Authored: Tue Jun 12 15:00:56 2018 -0400
Committer: Andrew Stitcher <astitcher@apache.org>
Committed: Tue Jun 12 15:00:56 2018 -0400

----------------------------------------------------------------------
 python/proton/_url.py            |  6 ++++--
 tests/python/proton_tests/url.py | 11 +++++++----
 2 files changed, 11 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccfd19ce/python/proton/_url.py
----------------------------------------------------------------------
diff --git a/python/proton/_url.py b/python/proton/_url.py
index 39cf480..c090106 100644
--- a/python/proton/_url.py
+++ b/python/proton/_url.py
@@ -103,8 +103,10 @@ class Url(object):
             self._query = url._query
             self._fragment = url._fragment
         elif url:
-            if not '://' in url:
-                url = '//' + url
+            if not url.startswith('//'):
+                p = url.partition(':')
+                if '/' in p[0] or not p[2].startswith('//'):
+                    url = '//' + url
             u = urlparse(url)
             if not u: raise ValueError("Invalid URL '%s'" % url)
             self.scheme = None if not u.scheme else u.scheme

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccfd19ce/tests/python/proton_tests/url.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/url.py b/tests/python/proton_tests/url.py
index 5b259c6..b44699a 100644
--- a/tests/python/proton_tests/url.py
+++ b/tests/python/proton_tests/url.py
@@ -54,10 +54,13 @@ class UrlTest(common.Test):
 
         # Expanding abbreviated url strings.
         for s, u in [
-                ("", "amqp://0.0.0.0:amqp"),
-                ("foo", "amqp://foo:amqp"),
-                (":1234", "amqp://0.0.0.0:1234"),
-                ("/path", "amqp://0.0.0.0:amqp/path")
+            ("", "amqp://0.0.0.0:amqp"),
+            ("foo", "amqp://foo:amqp"),
+            (":1234", "amqp://0.0.0.0:1234"),
+            ("/path", "amqp://0.0.0.0:amqp/path"),
+            ("user@host/topic://test", "amqp://user@host:amqp/topic://test"),
+            ("user@host:3456", "amqp://user@host:3456"),
+            ("user:pass@host/topic://test", "amqp://user:pass@host:amqp/topic://test")
         ]: self.assertEqual(str(Url(s)), u)
 
     def assertPort(self, port, portint, portstr):


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message