qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From astitc...@apache.org
Subject svn commit: r1576091 - /qpid/proton/trunk/proton-c/src/util.c
Date Mon, 10 Mar 2014 21:15:58 GMT
Author: astitcher
Date: Mon Mar 10 21:15:58 2014
New Revision: 1576091

URL: http://svn.apache.org/r1576091
Log:
PROTON-506: Fix C address URL parser to correctly identify the host component
if there is an '@' character in the path component.

Modified:
    qpid/proton/trunk/proton-c/src/util.c

Modified: qpid/proton/trunk/proton-c/src/util.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/util.c?rev=1576091&r1=1576090&r2=1576091&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/util.c (original)
+++ qpid/proton/trunk/proton-c/src/util.c Mon Mar 10 21:15:58 2014
@@ -112,43 +112,42 @@ void pn_print_data(const char *bytes, si
 // <path> can contain any character
 void pni_parse_url(char *url, char **scheme, char **user, char **pass, char **host, char
**port, char **path)
 {
-  if (url) {
-    char *scheme_end = strstr(url, "://");
-    if (scheme_end) {
-      *scheme_end = '\0';
-      *scheme = url;
-      url = scheme_end + 3;
-    }
+  if (!url) return;
 
-    char *at = strchr(url, '@');
-    if (at) {
-      *at = '\0';
-      char *up = url;
-      *user = up;
-      url = at + 1;
-      char *colon = strchr(up, ':');
-      if (colon) {
-        *colon = '\0';
-        *pass = colon + 1;
-      }
-    }
+  char *scheme_end = strstr(url, "://");
+  if (scheme_end) {
+    *scheme_end = '\0';
+    *scheme = url;
+    url = scheme_end + 3;
+  }
 
-    char *slash = strchr(url, '/');
-    if (slash) {
-      *slash = '\0';
-      *host = url;
-      url = slash + 1;
-      *path = url;
-    } else {
-      *host = url;
-    }
+  char *slash = strchr(url, '/');
+  if (slash) {
+    *slash = '\0';
+    *path = slash + 1;
+  }
 
-    char *colon = strchr(*host, ':');
+  char *at = strchr(url, '@');
+  if (at) {
+    *at = '\0';
+    char *up = url;
+    *user = up;
+    url = at + 1;
+    char *colon = strchr(up, ':');
     if (colon) {
       *colon = '\0';
-      *port = colon + 1;
+      *pass = colon + 1;
     }
   }
+
+  *host = url;
+
+  char *colon = strchr(*host, ':');
+  if (colon) {
+    *colon = '\0';
+    *port = colon + 1;
+  }
+
 }
 
 void pn_vfatal(const char *fmt, va_list ap)



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


Mime
View raw message