[libsoup] SoupRequestFile: fix handling of URIs with query components
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup] SoupRequestFile: fix handling of URIs with query components
- Date: Fri, 24 Feb 2012 16:58:10 +0000 (UTC)
commit bf2e998408466d904fb3561789869f1f3e88d7eb
Author: Dan Winship <danw gnome org>
Date: Fri Feb 24 11:55:45 2012 -0500
SoupRequestFile: fix handling of URIs with query components
At the moment, gio mishandles file: URIs with query components,
so strip them out before passing the URI to gio.
Also remove some useless code from an earlier incarnation of
SoupRequestFile.
libsoup/soup-request-file.c | 28 +++++++++++++++++-----------
1 files changed, 17 insertions(+), 11 deletions(-)
---
diff --git a/libsoup/soup-request-file.c b/libsoup/soup-request-file.c
index 116a3bf..a26d994 100644
--- a/libsoup/soup-request-file.c
+++ b/libsoup/soup-request-file.c
@@ -73,8 +73,7 @@ soup_request_file_check_uri (SoupRequest *request,
return FALSE;
/* but it must be "file:///..." or "file://localhost/..." */
- if (uri->scheme == SOUP_URI_SCHEME_FILE &&
- *uri->host &&
+ if (*uri->host &&
g_ascii_strcasecmp (uri->host, "localhost") != 0)
return FALSE;
@@ -86,23 +85,30 @@ soup_request_file_ensure_file (SoupRequestFile *file,
GCancellable *cancellable,
GError **error)
{
- SoupURI *uri;
+ SoupURI *uri, *copied_uri = NULL;
+ char *uri_str;
if (file->priv->gfile)
return TRUE;
uri = soup_request_get_uri (SOUP_REQUEST (file));
- if (uri->scheme == SOUP_URI_SCHEME_FILE) {
- gchar *file_uri = soup_uri_to_string (uri, FALSE);
- file->priv->gfile = g_file_new_for_uri (file_uri);
- g_free (file_uri);
- return TRUE;
+ /* gio mishandles URIs with query components:
+ * https://bugzilla.gnome.org/show_bug.cgi?id=670755
+ */
+ if (uri->query) {
+ uri = copied_uri = soup_uri_copy (uri);
+ soup_uri_set_query (copied_uri, NULL);
}
- g_set_error (error, SOUP_REQUESTER_ERROR, SOUP_REQUESTER_ERROR_UNSUPPORTED_URI_SCHEME,
- _("Unsupported URI scheme '%s'"), uri->scheme);
- return FALSE;
+ uri_str = soup_uri_to_string (uri, FALSE);
+ file->priv->gfile = g_file_new_for_uri (uri_str);
+
+ g_free (uri_str);
+ if (copied_uri)
+ soup_uri_free (copied_uri);
+
+ return TRUE;
}
static GInputStream *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]