minor rfc850-date parsing improvement suggested by RFC2616 19.3.
authorDan Winship <danw@src.gnome.org>
Tue, 25 Sep 2007 00:23:17 +0000 (00:23 +0000)
committerDan Winship <danw@src.gnome.org>
Tue, 25 Sep 2007 00:23:17 +0000 (00:23 +0000)
* libsoup/soup-date.c (soup_date_parse): minor rfc850-date parsing
improvement suggested by RFC2616 19.3.

* libsoup/soup-headers.c (soup_headers_parse_request): allow
erroneous trailing whitespace after HTTP version. #475169

* libsoup/soup-message-server-io.c (parse_request_headers): fix
the parsing of the Host header to assume it already includes the
port (which it should; the only reason this ever worked is because
SoupUri ignores the second port number when parse_request_headers
generates a URL like "http://localhost:9999:9999/").

* tests/header-parsing.c (reqtests): add a test for #475169

svn path=/trunk/; revision=933

ChangeLog
libsoup/soup-date.c
libsoup/soup-headers.c
libsoup/soup-message-server-io.c
tests/header-parsing.c

index 4a0dff8..8e3c018 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2007-09-24  Dan Winship  <danw@gnome.org>
+
+       * libsoup/soup-date.c (soup_date_parse): minor rfc850-date parsing
+       improvement suggested by RFC2616 19.3.
+
+       * libsoup/soup-headers.c (soup_headers_parse_request): allow
+       erroneous trailing whitespace after HTTP version. #475169
+
+       * libsoup/soup-message-server-io.c (parse_request_headers): fix
+       the parsing of the Host header to assume it already includes the
+       port (which it should; the only reason this ever worked is because
+       SoupUri ignores the second port number when parse_request_headers
+       generates a URL like "http://localhost:9999:9999/").
+
+       * tests/header-parsing.c (reqtests): add a test for #475169
+
 2007-09-23  Dan Winship  <danw@gnome.org>
 
        * libsoup/soup-message.c (soup_message_class_init): remove a
index e085366..6f92e74 100644 (file)
@@ -168,6 +168,8 @@ soup_date_parse (const char *timestamp)
                tm.tm_mday = atoi (timestamp + 2);
                tm.tm_mon = parse_month (timestamp + 5);
                tm.tm_year = atoi (timestamp + 9);
+               if (tm.tm_year < 70)
+                       tm.tm_year += 100;
                tm.tm_hour = atoi (timestamp + 12);
                tm.tm_min = atoi (timestamp + 15);
                tm.tm_sec = atoi (timestamp + 18);
index 7c6122c..dd7b516 100644 (file)
@@ -178,7 +178,7 @@ soup_headers_parse_request (const char       *str,
                return FALSE;
 
        headers = version + 8;
-       if (headers < str + len && *headers == '\r')
+       while (headers < str + len && (*headers == '\r' || *headers == ' '))
                headers++;
        if (headers >= str + len || *headers != '\n')
                return FALSE;
index 113760e..7927319 100644 (file)
@@ -71,10 +71,9 @@ parse_request_headers (SoupMessage *msg, char *headers, guint headers_len,
                        return SOUP_STATUS_BAD_REQUEST;
                }
        } else if (req_host) {
-               url = g_strdup_printf ("%s://%s:%d%s",
+               url = g_strdup_printf ("%s://%s%s",
                                       soup_server_get_protocol (server) == SOUP_PROTOCOL_HTTPS ? "https" : "http",
-                                      req_host, soup_server_get_port (server),
-                                      req_path);
+                                      req_host, req_path);
        } else if (priv->http_version == SOUP_HTTP_1_0) {
                /* No Host header, no AbsoluteUri */
                SoupAddress *addr = soup_socket_get_local_address (sock);
index 782967b..af4a1ec 100644 (file)
@@ -180,6 +180,14 @@ struct RequestTest {
          }
        },
 
+       { "Req w/ incorrect whitespace after Request-Line",
+         "GET / HTTP/1.1 \r\nHost: example.com\r\n", -1,
+         "GET", "/", SOUP_HTTP_1_1,
+         { { "Host", "example.com" },
+           { NULL }
+         }
+       },
+
        /************************/
        /*** INVALID REQUESTS ***/
        /************************/