apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rpl...@apache.org
Subject svn commit: r602690 - in /apr/apr-util/branches/1.2.x: CHANGES test/testuri.c uri/apr_uri.c
Date Sun, 09 Dec 2007 16:04:16 GMT
Author: rpluem
Date: Sun Dec  9 08:04:15 2007
New Revision: 602690

URL: http://svn.apache.org/viewvc?rev=602690&view=rev
Log:
Merge r594624 from trunk:

Add better scheme/host parsing to apr_uri.

Submitted by: Henry Jen <henryjen ztune.net>
Reviewed by: rpluem

Modified:
    apr/apr-util/branches/1.2.x/CHANGES
    apr/apr-util/branches/1.2.x/test/testuri.c
    apr/apr-util/branches/1.2.x/uri/apr_uri.c

Modified: apr/apr-util/branches/1.2.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.2.x/CHANGES?rev=602690&r1=602689&r2=602690&view=diff
==============================================================================
--- apr/apr-util/branches/1.2.x/CHANGES [utf-8] (original)
+++ apr/apr-util/branches/1.2.x/CHANGES [utf-8] Sun Dec  9 08:04:15 2007
@@ -2,6 +2,9 @@
 
 Changes with APR-util 1.2.13
 
+  *) Add better scheme/host parsing to apr_uri.
+     [Henry Jen <henryjen ztune.net>]
+
   *) Fix the make test target in the spec file. [Graham Leggett]
 
 Changes with APR-util 1.2.12

Modified: apr/apr-util/branches/1.2.x/test/testuri.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.2.x/test/testuri.c?rev=602690&r1=602689&r2=602690&view=diff
==============================================================================
--- apr/apr-util/branches/1.2.x/test/testuri.c (original)
+++ apr/apr-util/branches/1.2.x/test/testuri.c Sun Dec  9 08:04:15 2007
@@ -95,6 +95,30 @@
         "//www.apache.org/",
         0, NULL, "www.apache.org", NULL, NULL, "www.apache.org", NULL, "/", NULL, NULL, 0
     },
+    {
+        "file:image.jpg",
+        0, "file", NULL, NULL, NULL, NULL, NULL, "image.jpg", NULL, NULL, 0
+    },
+    {
+        "file:/image.jpg",
+        0, "file", NULL, NULL, NULL, NULL, NULL, "/image.jpg", NULL, NULL, 0
+    },
+    {
+        "file:///image.jpg",
+        0, "file", "", NULL, NULL, "", NULL, "/image.jpg", NULL, NULL, 0
+    },
+    {
+        "file:///tmp/photos/image.jpg",
+        0, "file", "", NULL, NULL, "", NULL, "/tmp/photos/image.jpg", NULL, NULL, 0
+    },
+    {
+        "file:./image.jpg",
+        0, "file", NULL, NULL, NULL, NULL, NULL, "./image.jpg", NULL, NULL, 0
+    },
+    {
+        "file:../photos/image.jpg",
+        0, "file", NULL, NULL, NULL, NULL, NULL, "../photos/image.jpg", NULL, NULL, 0
+    },
 };
 
 struct uph_test {

Modified: apr/apr-util/branches/1.2.x/uri/apr_uri.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.2.x/uri/apr_uri.c?rev=602690&r1=602689&r2=602690&view=diff
==============================================================================
--- apr/apr-util/branches/1.2.x/uri/apr_uri.c (original)
+++ apr/apr-util/branches/1.2.x/uri/apr_uri.c Sun Dec  9 08:04:15 2007
@@ -92,6 +92,12 @@
                                     unsigned flags)
 {
     char *ret = "";
+    char *scheme = NULL;
+
+    if (uptr->scheme) {
+        scheme = apr_pstrcat(p, uptr->scheme, ":", NULL);
+    }
+
 
     /* If suppressing the site part, omit both user name & scheme://hostname */
     if (!(flags & APR_URI_UNP_OMITSITEPART)) {
@@ -129,29 +135,15 @@
                  uptr->port == 0 ||
                  uptr->port == apr_uri_port_of_scheme(uptr->scheme));
 
-            if (uptr->scheme) {
-                ret = apr_pstrcat(p,
-                              uptr->scheme, "://", ret,
-                              lbrk, uptr->hostname, rbrk,
-                              is_default_port ? "" : ":",
-                              is_default_port ? "" : uptr->port_str,
-                              NULL);
-            }
-            else {
-                /* A violation of RFC2396, but it is clear from section 3.2
-                 * that the : belongs above to the scheme, while // belongs
-                 * to the authority, so include the authority prefix while
-                 * omitting the "scheme:" that the user neglected to pass us.
-                 */
-                ret = apr_pstrcat(p,
-                              "//", ret, lbrk, uptr->hostname, rbrk,
-                              is_default_port ? "" : ":",
-                              is_default_port ? "" : uptr->port_str,
-                              NULL);
-            }
+            ret = apr_pstrcat(p, "//", ret, lbrk, uptr->hostname, rbrk,
+                        is_default_port ? "" : ":",
+                        is_default_port ? "" : uptr->port_str,
+                        NULL);
         }
     }
 
+    ret = apr_pstrcat(p, scheme ? scheme : "", ret, NULL);
+    
     /* Should we suppress all path info? */
     if (!(flags & APR_URI_UNP_OMITPATHINFO)) {
         /* Append path, query and fragment strings: */
@@ -324,12 +316,17 @@
     while ((uri_delims[*(unsigned char *)s] & NOTEND_SCHEME) == 0) {
         ++s;
     }
-    /* scheme must be non-empty and followed by :// */
-    if (s == uri || s[0] != ':' || s[1] != '/' || s[2] != '/') {
+    /* scheme must be non-empty and followed by : */
+    if (s == uri || s[0] != ':') {
         goto deal_with_path;        /* backwards predicted taken! */
     }
 
     uptr->scheme = apr_pstrmemdup(p, uri, s - uri);
+    if (s[1] != '/' || s[2] != '/') {
+        uri = s + 1;
+        goto deal_with_path;
+    }
+
     s += 3;
 
 deal_with_authority:



Mime
View raw message