]> sjero.net Git - wget/commitdiff
[svn] Allow empty port spec in URL.
authorhniksic <devnull@localhost>
Fri, 7 Nov 2003 01:10:12 +0000 (17:10 -0800)
committerhniksic <devnull@localhost>
Fri, 7 Nov 2003 01:10:12 +0000 (17:10 -0800)
src/ChangeLog
src/url.c

index 702ccc7fa60ceaf1618d2ae84c6c907b9ebf4889..bf5f6ccb135e16a75901316a40a4e04d675ca1df 100644 (file)
@@ -1,3 +1,7 @@
+2003-11-07  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * url.c (url_parse): Allow empty ports.
+
 2003-11-07  Hrvoje Niksic  <hniksic@xemacs.org>
 
        * main.c (print_help): Break the help string into multiple chunks.
index dd93592a408a9392665fc09290a9a44f53c680fb..6b038f17f393369027263b1b7b72e08068e3feb5 100644 (file)
--- a/src/url.c
+++ b/src/url.c
@@ -78,7 +78,12 @@ static int path_simplify PARAMS ((char *));
 \f
 /* Support for encoding and decoding of URL strings.  We determine
    whether a character is unsafe through static table lookup.  This
-   code assumes ASCII character set and 8-bit chars.  */
+   code assumes ASCII character set and 8-bit chars.
+
+   Note that rfc2396 chose a different terminology from rfc1738.  The
+   recoding that URL does should be compliant with both specs,
+   although escaping the "unsafe" ("unreserved" in rfc2396 parlance)
+   chars where not strictly necessary is now frowned upon.  */
 
 enum {
   /* rfc1738 reserved chars, preserved from encoding.  */
@@ -103,8 +108,8 @@ const static unsigned char urlchr_table[256] =
   U,  U,  U,  U,   U,  U,  U,  U,   /* BS  HT  LF  VT   FF  CR  SO  SI  */
   U,  U,  U,  U,   U,  U,  U,  U,   /* DLE DC1 DC2 DC3  DC4 NAK SYN ETB */
   U,  U,  U,  U,   U,  U,  U,  U,   /* CAN EM  SUB ESC  FS  GS  RS  US  */
-  U,  0,  U, RU,   0,  U,  R,  0,   /* SP  !   "   #    $   %   &   '   */
-  0,  0,  0,  R,   0,  0,  0,  R,   /* (   )   *   +    ,   -   .   /   */
+  U,  0,  U, RU,   R,  U,  R,  0,   /* SP  !   "   #    $   %   &   '   */
+  0,  0,  0,  R,   R,  0,  0,  R,   /* (   )   *   +    ,   -   .   /   */
   0,  0,  0,  0,   0,  0,  0,  0,   /* 0   1   2   3    4   5   6   7   */
   0,  0, RU,  R,   U,  R,  U,  R,   /* 8   9   :   ;    <   =   >   ?   */
  RU,  0,  0,  0,   0,  0,  0,  0,   /* @   A   B   C    D   E   F   G   */
@@ -892,25 +897,20 @@ url_parse (const char *url, int *error)
       p = strpbrk_or_eos (p, "/;?#");
       port_e = p;
 
-      if (port_b == port_e)
-       {
-         /* http://host:/whatever */
-         /*             ^         */
-          error_code = PE_BAD_PORT_NUMBER;
-         goto error;
-       }
-
-      for (port = 0, pp = port_b; pp < port_e; pp++)
+      /* Allow empty port, as per rfc2396. */
+      if (port_b != port_e)
        {
-         if (!ISDIGIT (*pp))
+         for (port = 0, pp = port_b; pp < port_e; pp++)
            {
-             /* http://host:12randomgarbage/blah */
-             /*               ^                  */
-              error_code = PE_BAD_PORT_NUMBER;
-              goto error;
+             if (!ISDIGIT (*pp))
+               {
+                 /* http://host:12randomgarbage/blah */
+                 /*               ^                  */
+                 error_code = PE_BAD_PORT_NUMBER;
+                 goto error;
+               }
+             port = 10 * port + (*pp - '0');
            }
-         
-         port = 10 * port + (*pp - '0');
        }
     }