apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r1462434 - in /apr/apr-util/branches/1.5.x: ./ CHANGES test/testuri.c uri/apr_uri.c
Date Fri, 29 Mar 2013 10:17:32 GMT
Author: sf
Date: Fri Mar 29 10:17:31 2013
New Revision: 1462434

URL: http://svn.apache.org/r1462434
Log:
Merge r1462219,1462224:

    apr_uri_parse(): Do not accept invalid characters in the scheme.
    Per RFC 3986 3.3, enforce that the first segment of a relative path does
    not contain a colon.
    
    PR: 52479

Modified:
    apr/apr-util/branches/1.5.x/   (props changed)
    apr/apr-util/branches/1.5.x/CHANGES
    apr/apr-util/branches/1.5.x/test/testuri.c
    apr/apr-util/branches/1.5.x/uri/apr_uri.c

Propchange: apr/apr-util/branches/1.5.x/
------------------------------------------------------------------------------
  Merged /apr/apr/trunk:r1462219,1462224

Modified: apr/apr-util/branches/1.5.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.5.x/CHANGES?rev=1462434&r1=1462433&r2=1462434&view=diff
==============================================================================
--- apr/apr-util/branches/1.5.x/CHANGES [utf-8] (original)
+++ apr/apr-util/branches/1.5.x/CHANGES [utf-8] Fri Mar 29 10:17:31 2013
@@ -1,6 +1,10 @@
                                                      -*- coding: utf-8 -*-
 Changes with APR-util 1.5.2
 
+  *) apr_uri_parse(): Do not accept invalid characters in the scheme.
+     Per RFC 3986 3.3, enforce that the first segment of a relative path does
+     not contain a colon. PR 52479. [Stefan Fritsch]
+
   *) Fix memory leak in hook sorting function. PR 51256.
      [<horowity checkpoint com>]
 

Modified: apr/apr-util/branches/1.5.x/test/testuri.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.5.x/test/testuri.c?rev=1462434&r1=1462433&r2=1462434&view=diff
==============================================================================
--- apr/apr-util/branches/1.5.x/test/testuri.c (original)
+++ apr/apr-util/branches/1.5.x/test/testuri.c Fri Mar 29 10:17:31 2013
@@ -123,6 +123,66 @@ struct aup_test aup_tests[] =
         "file:../photos/image.jpg",
         0, "file", NULL, NULL, NULL, NULL, NULL, "../photos/image.jpg", NULL, NULL, 0
     },
+    {
+        "file+ssh-2:../photos/image.jpg",
+        0, "file+ssh-2", NULL, NULL, NULL, NULL, NULL, "../photos/image.jpg", NULL, NULL,
0
+    },
+    {
+        "script/foo.js",
+        0, NULL, NULL, NULL, NULL, NULL, NULL, "script/foo.js", NULL, NULL, 0
+    },
+    {
+        "../foo2.js",
+        0, NULL, NULL, NULL, NULL, NULL, NULL, "../foo2.js", NULL, NULL, 0
+    },
+    {
+        "foo3.js",
+        0, NULL, NULL, NULL, NULL, NULL, NULL, "foo3.js", NULL, NULL, 0
+    },
+    {
+        "_foo/bar",
+        0, NULL, NULL, NULL, NULL, NULL, NULL, "_foo/bar", NULL, NULL, 0
+    },
+    {
+        "_foo:/bar",
+        APR_EGENERAL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
+    },
+    {
+        "2foo:/bar",
+        APR_EGENERAL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
+    },
+    {
+        ".foo:/bar",
+        APR_EGENERAL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
+    },
+    {
+        "-foo:/bar",
+        APR_EGENERAL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
+    },
+    {
+        "+foo:/bar",
+        APR_EGENERAL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
+    },
+    {
+        "::/bar",
+        APR_EGENERAL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
+    },
+    {
+        ":/bar",
+        APR_EGENERAL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
+    },
+    {
+        ":foo",
+        APR_EGENERAL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
+    },
+    {
+        ":",
+        APR_EGENERAL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
+    },
+    {
+        "@localhost::8080",
+        APR_EGENERAL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0
+    },
 };
 
 struct uph_test {

Modified: apr/apr-util/branches/1.5.x/uri/apr_uri.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.5.x/uri/apr_uri.c?rev=1462434&r1=1462433&r2=1462434&view=diff
==============================================================================
--- apr/apr-util/branches/1.5.x/uri/apr_uri.c (original)
+++ apr/apr-util/branches/1.5.x/uri/apr_uri.c Fri Mar 29 10:17:31 2013
@@ -170,51 +170,534 @@ APU_DECLARE(char *) apr_uri_unparse(apr_
  * compares for NUL for free -- it's just another delimiter.
  */
 
-#define T_COLON           0x01        /* ':' */
-#define T_SLASH           0x02        /* '/' */
-#define T_QUESTION        0x04        /* '?' */
-#define T_HASH            0x08        /* '#' */
+#define T_SLASH           0x01        /* '/' */
+#define T_QUESTION        0x02        /* '?' */
+#define T_HASH            0x04        /* '#' */
+#define T_ALPHA           0x08        /* 'A' ... 'Z', 'a' ... 'z' */
+#define T_SCHEME          0x10        /* '0' ... '9', '-', '+', '.'
+                                       * (allowed in scheme except first char)
+                                       */
 #define T_NUL             0x80        /* '\0' */
 
 #if APR_CHARSET_EBCDIC
 /* Delimiter table for the EBCDIC character set */
 static const unsigned char uri_delims[256] = {
-    T_NUL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,T_SLASH,0,0,0,0,0,0,0,0,0,0,0,0,0,T_QUESTION,
-    0,0,0,0,0,0,0,0,0,0,T_COLON,T_HASH,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+    T_NUL,                      /* 0x00     */
+    0,                          /* 0x01     */
+    0,                          /* 0x02     */
+    0,                          /* 0x03     */
+    0,                          /* 0x04     */
+    0,                          /* 0x05     */
+    0,                          /* 0x06     */
+    0,                          /* 0x07     */
+    0,                          /* 0x08     */
+    0,                          /* 0x09     */
+    0,                          /* 0x0a     */
+    0,                          /* 0x0b     */
+    0,                          /* 0x0c     */
+    0,                          /* 0x0d     */
+    0,                          /* 0x0e     */
+    0,                          /* 0x0f     */
+    0,                          /* 0x10     */
+    0,                          /* 0x11     */
+    0,                          /* 0x12     */
+    0,                          /* 0x13     */
+    0,                          /* 0x14     */
+    0,                          /* 0x15     */
+    0,                          /* 0x16     */
+    0,                          /* 0x17     */
+    0,                          /* 0x18     */
+    0,                          /* 0x19     */
+    0,                          /* 0x1a     */
+    0,                          /* 0x1b     */
+    0,                          /* 0x1c     */
+    0,                          /* 0x1d     */
+    0,                          /* 0x1e     */
+    0,                          /* 0x1f     */
+    0,                          /* 0x20     */
+    0,                          /* 0x21     */
+    0,                          /* 0x22     */
+    0,                          /* 0x23     */
+    0,                          /* 0x24     */
+    0,                          /* 0x25     */
+    0,                          /* 0x26     */
+    0,                          /* 0x27     */
+    0,                          /* 0x28     */
+    0,                          /* 0x29     */
+    0,                          /* 0x2a     */
+    0,                          /* 0x2b     */
+    0,                          /* 0x2c     */
+    0,                          /* 0x2d     */
+    0,                          /* 0x2e     */
+    0,                          /* 0x2f     */
+    0,                          /* 0x30     */
+    0,                          /* 0x31     */
+    0,                          /* 0x32     */
+    0,                          /* 0x33     */
+    0,                          /* 0x34     */
+    0,                          /* 0x35     */
+    0,                          /* 0x36     */
+    0,                          /* 0x37     */
+    0,                          /* 0x38     */
+    0,                          /* 0x39     */
+    0,                          /* 0x3a     */
+    0,                          /* 0x3b     */
+    0,                          /* 0x3c     */
+    0,                          /* 0x3d     */
+    0,                          /* 0x3e     */
+    0,                          /* 0x3f     */
+    0,                          /* 0x40 ' ' */
+    0,                          /* 0x41     */
+    0,                          /* 0x42     */
+    0,                          /* 0x43     */
+    0,                          /* 0x44     */
+    0,                          /* 0x45     */
+    0,                          /* 0x46     */
+    0,                          /* 0x47     */
+    0,                          /* 0x48     */
+    0,                          /* 0x49     */
+    0,                          /* 0x4a '[' */
+    T_SCHEME,                   /* 0x4b '.' */
+    0,                          /* 0x4c '<' */
+    0,                          /* 0x4d '(' */
+    T_SCHEME,                   /* 0x4e '+' */
+    0,                          /* 0x4f '!' */
+    0,                          /* 0x50 '&' */
+    0,                          /* 0x51     */
+    0,                          /* 0x52     */
+    0,                          /* 0x53     */
+    0,                          /* 0x54     */
+    0,                          /* 0x55     */
+    0,                          /* 0x56     */
+    0,                          /* 0x57     */
+    0,                          /* 0x58     */
+    0,                          /* 0x59     */
+    0,                          /* 0x5a ']' */
+    0,                          /* 0x5b '$' */
+    0,                          /* 0x5c '*' */
+    0,                          /* 0x5d ')' */
+    0,                          /* 0x5e ';' */
+    0,                          /* 0x5f '^' */
+    T_SCHEME,                   /* 0x60 '-' */
+    T_SLASH,                    /* 0x61 '/' */
+    0,                          /* 0x62     */
+    0,                          /* 0x63     */
+    0,                          /* 0x64     */
+    0,                          /* 0x65     */
+    0,                          /* 0x66     */
+    0,                          /* 0x67     */
+    0,                          /* 0x68     */
+    0,                          /* 0x69     */
+    0,                          /* 0x6a '|' */
+    0,                          /* 0x6b ',' */
+    0,                          /* 0x6c '%' */
+    0,                          /* 0x6d '_' */
+    0,                          /* 0x6e '>' */
+    T_QUESTION,                 /* 0x6f '?' */
+    0,                          /* 0x70     */
+    0,                          /* 0x71     */
+    0,                          /* 0x72     */
+    0,                          /* 0x73     */
+    0,                          /* 0x74     */
+    0,                          /* 0x75     */
+    0,                          /* 0x76     */
+    0,                          /* 0x77     */
+    0,                          /* 0x78     */
+    0,                          /* 0x79 '`' */
+    0,                          /* 0x7a ':' */
+    T_HASH,                     /* 0x7b '#' */
+    0,                          /* 0x7c '@' */
+    0,                          /* 0x7d ''' */
+    0,                          /* 0x7e '=' */
+    0,                          /* 0x7f '"' */
+    0,                          /* 0x80     */
+    T_ALPHA,                    /* 0x81 'a' */
+    T_ALPHA,                    /* 0x82 'b' */
+    T_ALPHA,                    /* 0x83 'c' */
+    T_ALPHA,                    /* 0x84 'd' */
+    T_ALPHA,                    /* 0x85 'e' */
+    T_ALPHA,                    /* 0x86 'f' */
+    T_ALPHA,                    /* 0x87 'g' */
+    T_ALPHA,                    /* 0x88 'h' */
+    T_ALPHA,                    /* 0x89 'i' */
+    0,                          /* 0x8a     */
+    0,                          /* 0x8b     */
+    0,                          /* 0x8c     */
+    0,                          /* 0x8d     */
+    0,                          /* 0x8e     */
+    0,                          /* 0x8f     */
+    0,                          /* 0x90     */
+    T_ALPHA,                    /* 0x91 'j' */
+    T_ALPHA,                    /* 0x92 'k' */
+    T_ALPHA,                    /* 0x93 'l' */
+    T_ALPHA,                    /* 0x94 'm' */
+    T_ALPHA,                    /* 0x95 'n' */
+    T_ALPHA,                    /* 0x96 'o' */
+    T_ALPHA,                    /* 0x97 'p' */
+    T_ALPHA,                    /* 0x98 'q' */
+    T_ALPHA,                    /* 0x99 'r' */
+    0,                          /* 0x9a     */
+    0,                          /* 0x9b     */
+    0,                          /* 0x9c     */
+    0,                          /* 0x9d     */
+    0,                          /* 0x9e     */
+    0,                          /* 0x9f     */
+    0,                          /* 0xa0     */
+    0,                          /* 0xa1 '~' */
+    T_ALPHA,                    /* 0xa2 's' */
+    T_ALPHA,                    /* 0xa3 't' */
+    T_ALPHA,                    /* 0xa4 'u' */
+    T_ALPHA,                    /* 0xa5 'v' */
+    T_ALPHA,                    /* 0xa6 'w' */
+    T_ALPHA,                    /* 0xa7 'x' */
+    T_ALPHA,                    /* 0xa8 'y' */
+    T_ALPHA,                    /* 0xa9 'z' */
+    0,                          /* 0xaa     */
+    0,                          /* 0xab     */
+    0,                          /* 0xac     */
+    0,                          /* 0xad     */
+    0,                          /* 0xae     */
+    0,                          /* 0xaf     */
+    0,                          /* 0xb0     */
+    0,                          /* 0xb1     */
+    0,                          /* 0xb2     */
+    0,                          /* 0xb3     */
+    0,                          /* 0xb4     */
+    0,                          /* 0xb5     */
+    0,                          /* 0xb6     */
+    0,                          /* 0xb7     */
+    0,                          /* 0xb8     */
+    0,                          /* 0xb9     */
+    0,                          /* 0xba     */
+    0,                          /* 0xbb     */
+    0,                          /* 0xbc     */
+    0,                          /* 0xbd     */
+    0,                          /* 0xbe     */
+    0,                          /* 0xbf     */
+    0,                          /* 0xc0 '{' */
+    T_ALPHA,                    /* 0xc1 'A' */
+    T_ALPHA,                    /* 0xc2 'B' */
+    T_ALPHA,                    /* 0xc3 'C' */
+    T_ALPHA,                    /* 0xc4 'D' */
+    T_ALPHA,                    /* 0xc5 'E' */
+    T_ALPHA,                    /* 0xc6 'F' */
+    T_ALPHA,                    /* 0xc7 'G' */
+    T_ALPHA,                    /* 0xc8 'H' */
+    T_ALPHA,                    /* 0xc9 'I' */
+    0,                          /* 0xca     */
+    0,                          /* 0xcb     */
+    0,                          /* 0xcc     */
+    0,                          /* 0xcd     */
+    0,                          /* 0xce     */
+    0,                          /* 0xcf     */
+    0,                          /* 0xd0 '}' */
+    T_ALPHA,                    /* 0xd1 'J' */
+    T_ALPHA,                    /* 0xd2 'K' */
+    T_ALPHA,                    /* 0xd3 'L' */
+    T_ALPHA,                    /* 0xd4 'M' */
+    T_ALPHA,                    /* 0xd5 'N' */
+    T_ALPHA,                    /* 0xd6 'O' */
+    T_ALPHA,                    /* 0xd7 'P' */
+    T_ALPHA,                    /* 0xd8 'Q' */
+    T_ALPHA,                    /* 0xd9 'R' */
+    0,                          /* 0xda     */
+    0,                          /* 0xdb     */
+    0,                          /* 0xdc     */
+    0,                          /* 0xdd     */
+    0,                          /* 0xde     */
+    0,                          /* 0xdf     */
+    0,                          /* 0xe0 '\' */
+    0,                          /* 0xe1     */
+    T_ALPHA,                    /* 0xe2 'S' */
+    T_ALPHA,                    /* 0xe3 'T' */
+    T_ALPHA,                    /* 0xe4 'U' */
+    T_ALPHA,                    /* 0xe5 'V' */
+    T_ALPHA,                    /* 0xe6 'W' */
+    T_ALPHA,                    /* 0xe7 'X' */
+    T_ALPHA,                    /* 0xe8 'Y' */
+    T_ALPHA,                    /* 0xe9 'Z' */
+    0,                          /* 0xea     */
+    0,                          /* 0xeb     */
+    0,                          /* 0xec     */
+    0,                          /* 0xed     */
+    0,                          /* 0xee     */
+    0,                          /* 0xef     */
+    T_SCHEME,                   /* 0xf0 '0' */
+    T_SCHEME,                   /* 0xf1 '1' */
+    T_SCHEME,                   /* 0xf2 '2' */
+    T_SCHEME,                   /* 0xf3 '3' */
+    T_SCHEME,                   /* 0xf4 '4' */
+    T_SCHEME,                   /* 0xf5 '5' */
+    T_SCHEME,                   /* 0xf6 '6' */
+    T_SCHEME,                   /* 0xf7 '7' */
+    T_SCHEME,                   /* 0xf8 '8' */
+    T_SCHEME,                   /* 0xf9 '9' */
+    0,                          /* 0xfa     */
+    0,                          /* 0xfb     */
+    0,                          /* 0xfc     */
+    0,                          /* 0xfd     */
+    0,                          /* 0xfe     */
+    0                           /* 0xff     */
 };
 #else
 /* Delimiter table for the ASCII character set */
 static const unsigned char uri_delims[256] = {
-    T_NUL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,T_HASH,0,0,0,0,0,0,0,0,0,0,0,T_SLASH,
-    0,0,0,0,0,0,0,0,0,0,T_COLON,0,0,0,0,T_QUESTION,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+    T_NUL,                      /* 0x00     */
+    0,                          /* 0x01     */
+    0,                          /* 0x02     */
+    0,                          /* 0x03     */
+    0,                          /* 0x04     */
+    0,                          /* 0x05     */
+    0,                          /* 0x06     */
+    0,                          /* 0x07     */
+    0,                          /* 0x08     */
+    0,                          /* 0x09     */
+    0,                          /* 0x0a     */
+    0,                          /* 0x0b     */
+    0,                          /* 0x0c     */
+    0,                          /* 0x0d     */
+    0,                          /* 0x0e     */
+    0,                          /* 0x0f     */
+    0,                          /* 0x10     */
+    0,                          /* 0x11     */
+    0,                          /* 0x12     */
+    0,                          /* 0x13     */
+    0,                          /* 0x14     */
+    0,                          /* 0x15     */
+    0,                          /* 0x16     */
+    0,                          /* 0x17     */
+    0,                          /* 0x18     */
+    0,                          /* 0x19     */
+    0,                          /* 0x1a     */
+    0,                          /* 0x1b     */
+    0,                          /* 0x1c     */
+    0,                          /* 0x1d     */
+    0,                          /* 0x1e     */
+    0,                          /* 0x1f     */
+    0,                          /* 0x20 ' ' */
+    0,                          /* 0x21 '!' */
+    0,                          /* 0x22 '"' */
+    T_HASH,                     /* 0x23 '#' */
+    0,                          /* 0x24 '$' */
+    0,                          /* 0x25 '%' */
+    0,                          /* 0x26 '&' */
+    0,                          /* 0x27 ''' */
+    0,                          /* 0x28 '(' */
+    0,                          /* 0x29 ')' */
+    0,                          /* 0x2a '*' */
+    T_SCHEME,                   /* 0x2b '+' */
+    0,                          /* 0x2c ',' */
+    T_SCHEME,                   /* 0x2d '-' */
+    T_SCHEME,                   /* 0x2e '.' */
+    T_SLASH,                    /* 0x2f '/' */
+    T_SCHEME,                   /* 0x30 '0' */
+    T_SCHEME,                   /* 0x31 '1' */
+    T_SCHEME,                   /* 0x32 '2' */
+    T_SCHEME,                   /* 0x33 '3' */
+    T_SCHEME,                   /* 0x34 '4' */
+    T_SCHEME,                   /* 0x35 '5' */
+    T_SCHEME,                   /* 0x36 '6' */
+    T_SCHEME,                   /* 0x37 '7' */
+    T_SCHEME,                   /* 0x38 '8' */
+    T_SCHEME,                   /* 0x39 '9' */
+    0,                          /* 0x3a ':' */
+    0,                          /* 0x3b ';' */
+    0,                          /* 0x3c '<' */
+    0,                          /* 0x3d '=' */
+    0,                          /* 0x3e '>' */
+    T_QUESTION,                 /* 0x3f '?' */
+    0,                          /* 0x40 '@' */
+    T_ALPHA,                    /* 0x41 'A' */
+    T_ALPHA,                    /* 0x42 'B' */
+    T_ALPHA,                    /* 0x43 'C' */
+    T_ALPHA,                    /* 0x44 'D' */
+    T_ALPHA,                    /* 0x45 'E' */
+    T_ALPHA,                    /* 0x46 'F' */
+    T_ALPHA,                    /* 0x47 'G' */
+    T_ALPHA,                    /* 0x48 'H' */
+    T_ALPHA,                    /* 0x49 'I' */
+    T_ALPHA,                    /* 0x4a 'J' */
+    T_ALPHA,                    /* 0x4b 'K' */
+    T_ALPHA,                    /* 0x4c 'L' */
+    T_ALPHA,                    /* 0x4d 'M' */
+    T_ALPHA,                    /* 0x4e 'N' */
+    T_ALPHA,                    /* 0x4f 'O' */
+    T_ALPHA,                    /* 0x50 'P' */
+    T_ALPHA,                    /* 0x51 'Q' */
+    T_ALPHA,                    /* 0x52 'R' */
+    T_ALPHA,                    /* 0x53 'S' */
+    T_ALPHA,                    /* 0x54 'T' */
+    T_ALPHA,                    /* 0x55 'U' */
+    T_ALPHA,                    /* 0x56 'V' */
+    T_ALPHA,                    /* 0x57 'W' */
+    T_ALPHA,                    /* 0x58 'X' */
+    T_ALPHA,                    /* 0x59 'Y' */
+    T_ALPHA,                    /* 0x5a 'Z' */
+    0,                          /* 0x5b '[' */
+    0,                          /* 0x5c '\' */
+    0,                          /* 0x5d ']' */
+    0,                          /* 0x5e '^' */
+    0,                          /* 0x5f '_' */
+    0,                          /* 0x60 '`' */
+    T_ALPHA,                    /* 0x61 'a' */
+    T_ALPHA,                    /* 0x62 'b' */
+    T_ALPHA,                    /* 0x63 'c' */
+    T_ALPHA,                    /* 0x64 'd' */
+    T_ALPHA,                    /* 0x65 'e' */
+    T_ALPHA,                    /* 0x66 'f' */
+    T_ALPHA,                    /* 0x67 'g' */
+    T_ALPHA,                    /* 0x68 'h' */
+    T_ALPHA,                    /* 0x69 'i' */
+    T_ALPHA,                    /* 0x6a 'j' */
+    T_ALPHA,                    /* 0x6b 'k' */
+    T_ALPHA,                    /* 0x6c 'l' */
+    T_ALPHA,                    /* 0x6d 'm' */
+    T_ALPHA,                    /* 0x6e 'n' */
+    T_ALPHA,                    /* 0x6f 'o' */
+    T_ALPHA,                    /* 0x70 'p' */
+    T_ALPHA,                    /* 0x71 'q' */
+    T_ALPHA,                    /* 0x72 'r' */
+    T_ALPHA,                    /* 0x73 's' */
+    T_ALPHA,                    /* 0x74 't' */
+    T_ALPHA,                    /* 0x75 'u' */
+    T_ALPHA,                    /* 0x76 'v' */
+    T_ALPHA,                    /* 0x77 'w' */
+    T_ALPHA,                    /* 0x78 'x' */
+    T_ALPHA,                    /* 0x79 'y' */
+    T_ALPHA,                    /* 0x7a 'z' */
+    0,                          /* 0x7b '{' */
+    0,                          /* 0x7c '|' */
+    0,                          /* 0x7d '}' */
+    0,                          /* 0x7e '~' */
+    0,                          /* 0x7f     */
+    0,                          /* 0x80     */
+    0,                          /* 0x81     */
+    0,                          /* 0x82     */
+    0,                          /* 0x83     */
+    0,                          /* 0x84     */
+    0,                          /* 0x85     */
+    0,                          /* 0x86     */
+    0,                          /* 0x87     */
+    0,                          /* 0x88     */
+    0,                          /* 0x89     */
+    0,                          /* 0x8a     */
+    0,                          /* 0x8b     */
+    0,                          /* 0x8c     */
+    0,                          /* 0x8d     */
+    0,                          /* 0x8e     */
+    0,                          /* 0x8f     */
+    0,                          /* 0x90     */
+    0,                          /* 0x91     */
+    0,                          /* 0x92     */
+    0,                          /* 0x93     */
+    0,                          /* 0x94     */
+    0,                          /* 0x95     */
+    0,                          /* 0x96     */
+    0,                          /* 0x97     */
+    0,                          /* 0x98     */
+    0,                          /* 0x99     */
+    0,                          /* 0x9a     */
+    0,                          /* 0x9b     */
+    0,                          /* 0x9c     */
+    0,                          /* 0x9d     */
+    0,                          /* 0x9e     */
+    0,                          /* 0x9f     */
+    0,                          /* 0xa0     */
+    0,                          /* 0xa1     */
+    0,                          /* 0xa2     */
+    0,                          /* 0xa3     */
+    0,                          /* 0xa4     */
+    0,                          /* 0xa5     */
+    0,                          /* 0xa6     */
+    0,                          /* 0xa7     */
+    0,                          /* 0xa8     */
+    0,                          /* 0xa9     */
+    0,                          /* 0xaa     */
+    0,                          /* 0xab     */
+    0,                          /* 0xac     */
+    0,                          /* 0xad     */
+    0,                          /* 0xae     */
+    0,                          /* 0xaf     */
+    0,                          /* 0xb0     */
+    0,                          /* 0xb1     */
+    0,                          /* 0xb2     */
+    0,                          /* 0xb3     */
+    0,                          /* 0xb4     */
+    0,                          /* 0xb5     */
+    0,                          /* 0xb6     */
+    0,                          /* 0xb7     */
+    0,                          /* 0xb8     */
+    0,                          /* 0xb9     */
+    0,                          /* 0xba     */
+    0,                          /* 0xbb     */
+    0,                          /* 0xbc     */
+    0,                          /* 0xbd     */
+    0,                          /* 0xbe     */
+    0,                          /* 0xbf     */
+    0,                          /* 0xc0     */
+    0,                          /* 0xc1     */
+    0,                          /* 0xc2     */
+    0,                          /* 0xc3     */
+    0,                          /* 0xc4     */
+    0,                          /* 0xc5     */
+    0,                          /* 0xc6     */
+    0,                          /* 0xc7     */
+    0,                          /* 0xc8     */
+    0,                          /* 0xc9     */
+    0,                          /* 0xca     */
+    0,                          /* 0xcb     */
+    0,                          /* 0xcc     */
+    0,                          /* 0xcd     */
+    0,                          /* 0xce     */
+    0,                          /* 0xcf     */
+    0,                          /* 0xd0     */
+    0,                          /* 0xd1     */
+    0,                          /* 0xd2     */
+    0,                          /* 0xd3     */
+    0,                          /* 0xd4     */
+    0,                          /* 0xd5     */
+    0,                          /* 0xd6     */
+    0,                          /* 0xd7     */
+    0,                          /* 0xd8     */
+    0,                          /* 0xd9     */
+    0,                          /* 0xda     */
+    0,                          /* 0xdb     */
+    0,                          /* 0xdc     */
+    0,                          /* 0xdd     */
+    0,                          /* 0xde     */
+    0,                          /* 0xdf     */
+    0,                          /* 0xe0     */
+    0,                          /* 0xe1     */
+    0,                          /* 0xe2     */
+    0,                          /* 0xe3     */
+    0,                          /* 0xe4     */
+    0,                          /* 0xe5     */
+    0,                          /* 0xe6     */
+    0,                          /* 0xe7     */
+    0,                          /* 0xe8     */
+    0,                          /* 0xe9     */
+    0,                          /* 0xea     */
+    0,                          /* 0xeb     */
+    0,                          /* 0xec     */
+    0,                          /* 0xed     */
+    0,                          /* 0xee     */
+    0,                          /* 0xef     */
+    0,                          /* 0xf0     */
+    0,                          /* 0xf1     */
+    0,                          /* 0xf2     */
+    0,                          /* 0xf3     */
+    0,                          /* 0xf4     */
+    0,                          /* 0xf5     */
+    0,                          /* 0xf6     */
+    0,                          /* 0xf7     */
+    0,                          /* 0xf8     */
+    0,                          /* 0xf9     */
+    0,                          /* 0xfa     */
+    0,                          /* 0xfb     */
+    0,                          /* 0xfc     */
+    0,                          /* 0xfd     */
+    0,                          /* 0xfe     */
+    0                           /* 0xff     */
 };
 #endif
 
@@ -225,10 +708,6 @@ static const unsigned char uri_delims[25
     }
 */
 
-/* Note that we optimize the scheme scanning here, we cheat and let the
- * compiler know that it doesn't have to do the & masking.
- */
-#define NOTEND_SCHEME     (0xff)
 #define NOTEND_HOSTINFO   (T_SLASH | T_QUESTION | T_HASH | T_NUL)
 #define NOTEND_PATH       (T_QUESTION | T_HASH | T_NUL)
 
@@ -308,21 +787,50 @@ deal_with_path:
 
     /* find the scheme: */
     s = uri;
-    while ((uri_delims[*(unsigned char *)s] & NOTEND_SCHEME) == 0) {
+    /* first char must be letter */
+    if (uri_delims[*(unsigned char *)s] & T_ALPHA) {
         ++s;
+        while ((uri_delims[*(unsigned char *)s] & (T_ALPHA|T_SCHEME)))
+            ++s;
     }
     /* scheme must be non-empty and followed by : */
-    if (s == uri || s[0] != ':') {
-        goto deal_with_path;        /* backwards predicted taken! */
+    if (s != uri && s[0] == ':') {
+        uptr->scheme = apr_pstrmemdup(p, uri, s - uri);
+        s++;
+    }
+    else {
+        /* No valid scheme, restart from the beginning */
+        s = uri;
     }
 
-    uptr->scheme = apr_pstrmemdup(p, uri, s - uri);
-    if (s[1] != '/' || s[2] != '/') {
-        uri = s + 1;
+    if (s[0] != '/' || s[1] != '/') {
+        if (uri == s) {
+            /*
+             * RFC 3986 3.3: If we have no scheme and no authority,
+             * the leading segment of a relative path must not contain a ':'.
+             */
+            char *first_slash = strchr(uri, '/');
+            if (first_slash) {
+                while (s < first_slash) {
+                    if (s[0] == ':')
+                        return APR_EGENERAL;
+                    ++s;
+                }
+                /* no scheme but relative path, e.g. '../image.jpg' */
+            }
+            else {
+                if (strchr(uri, ':') != NULL)
+                    return APR_EGENERAL;
+                /* no scheme, no slash, but relative path, e.g. 'image.jpg' */
+            }
+            goto deal_with_path;
+        }
+        /* scheme and relative path */
+        uri = s;
         goto deal_with_path;
     }
 
-    s += 3;
+    s += 2;
 
 deal_with_authority:
     hostinfo = s;



Mime
View raw message