Explicitly document the fact that you have to call soup_uri_set_path()
authorDan Winship <danw@src.gnome.org>
Tue, 9 Dec 2008 19:53:49 +0000 (19:53 +0000)
committerDan Winship <danw@src.gnome.org>
Tue, 9 Dec 2008 19:53:49 +0000 (19:53 +0000)
* libsoup/soup-uri.c (soup_uri_new): Explicitly document the fact
that you have to call soup_uri_set_path() when using
soup_uri_new(NULL), since path is required to be non-%NULL.

* libsoup/soup-connection.c (connect_message): initialize
uri->path

* libsoup/soup-cookie.c (soup_cookie_applies_to_uri):
g_return_val_if_fail() rather than crashing if uri->path is %NULL.
Also, fix the cookie/uri path comparison to not potentially read
off the end of uri->path. #562191, Mark Lee.

svn path=/trunk/; revision=1221

ChangeLog
libsoup/soup-connection.c
libsoup/soup-cookie.c
libsoup/soup-uri.c

index 760be25..49acb0f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2008-12-09  Dan Winship  <danw@gnome.org>
+
+       * libsoup/soup-uri.c (soup_uri_new): Explicitly document the fact
+       that you have to call soup_uri_set_path() when using
+       soup_uri_new(NULL), since path is required to be non-%NULL.
+
+       * libsoup/soup-connection.c (connect_message): initialize
+       uri->path
+
+       * libsoup/soup-cookie.c (soup_cookie_applies_to_uri):
+       g_return_val_if_fail() rather than crashing if uri->path is %NULL.
+       Also, fix the cookie/uri path comparison to not potentially read
+       off the end of uri->path. #562191, Mark Lee.
+
 2008-12-04  Dan Winship  <danw@gnome.org>
 
        * libsoup/soup-form.c (soup_form_decode): Correctly handle forms
index 042e225..4671ce9 100644 (file)
@@ -418,6 +418,7 @@ connect_message (SoupConnectionPrivate *priv)
        soup_uri_set_scheme (uri, SOUP_URI_SCHEME_HTTPS);
        soup_uri_set_host (uri, soup_address_get_name (priv->server_addr));
        soup_uri_set_port (uri, soup_address_get_port (priv->server_addr));
+       soup_uri_set_path (uri, "");
        msg = soup_message_new_from_uri (SOUP_METHOD_CONNECT, uri);
        soup_uri_free (uri);
 
index d009220..2a61cc5 100644 (file)
@@ -916,16 +916,21 @@ soup_cookie_applies_to_uri (SoupCookie *cookie, SoupURI *uri)
        if (cookie->expires && soup_date_is_past (cookie->expires))
                return FALSE;
 
+       /* uri->path is required to be non-NULL */
+       g_return_val_if_fail (uri->path != NULL, FALSE);
+
        /* The spec claims "/foo would match /foobar", but fortunately
         * no one is really that crazy.
         */
        plen = strlen (cookie->path);
        if (cookie->path[plen - 1] == '/')
                plen--;
+       if (strncmp (cookie->path, uri->path, plen) != 0)
+               return FALSE;
        if (uri->path[plen] && uri->path[plen] != '/')
                return FALSE;
 
-       return !strncmp (cookie->path, uri->path, plen);
+       return TRUE;
 }
 
 gboolean
index 52ffd1a..cf29582 100644 (file)
@@ -372,7 +372,9 @@ soup_uri_new_with_base (SoupURI *base, const char *uri_string)
  * Parses an absolute URI.
  *
  * You can also pass %NULL for @uri_string if you want to get back an
- * "empty" #SoupURI that you can fill in by hand.
+ * "empty" #SoupURI that you can fill in by hand. (You will need to
+ * call at least soup_uri_set_scheme() and soup_uri_set_path(), since
+ * those fields are required.)
  *
  * Return value: a #SoupURI, or %NULL.
  **/