diff options
author | Christian Kellner <gicmo@gnome.org> | 2011-05-17 18:38:56 +0200 |
---|---|---|
committer | Christian Kellner <gicmo@gnome.org> | 2011-05-18 14:25:38 +0200 |
commit | a319d7dca61f19c2b369c3a8a3d7269dd61827f6 (patch) | |
tree | 7f4d682df04e7453b46e87771073e765d834e190 | |
parent | e17226fac90b595ff8bac3cfd16530961f8bc4cc (diff) | |
download | gvfs-a319d7dca61f19c2b369c3a8a3d7269dd61827f6.tar.gz |
dav: Decode the paths of the multistatus response before comparing them
When doing a PROPFIND to stat () a location we have to find the "target"
response element that we did the PROPFIND for. We do this by comparing
the URL given by the href sub-element of the response element. Before
doing this comparison we have to decode the URL to make sure to ignore
encoding differences. Fixes bug 629660.
-rw-r--r-- | daemon/gvfsbackenddav.c | 93 |
1 files changed, 49 insertions, 44 deletions
diff --git a/daemon/gvfsbackenddav.c b/daemon/gvfsbackenddav.c index f1e1d750..228e87e8 100644 --- a/daemon/gvfsbackenddav.c +++ b/daemon/gvfsbackenddav.c @@ -709,15 +709,17 @@ struct _Multistatus { xmlNodePtr root; SoupURI *target; + char *path; }; struct _MsResponse { Multistatus *multistatus; + char *path; + gboolean is_target; + xmlNodePtr first_propstat; - xmlNodePtr href; - xmlNodePtr first_propstat; }; struct _MsPropstat { @@ -733,17 +735,21 @@ struct _MsPropstat { static gboolean multistatus_parse (SoupMessage *msg, Multistatus *multistatus, GError **error) { - xmlDocPtr doc; - xmlNodePtr root; + xmlDocPtr doc; + xmlNodePtr root; + SoupURI *uri; doc = parse_xml (msg, &root, "multistatus", error); if (doc == NULL) return FALSE; + uri = soup_message_get_uri (msg); + multistatus->doc = doc; multistatus->root = root; - multistatus->target = soup_message_get_uri (msg); + multistatus->target = uri; + multistatus->path = g_uri_unescape_string (uri->path, "/"); return TRUE; } @@ -752,6 +758,7 @@ static void multistatus_free (Multistatus *multistatus) { xmlFreeDoc (multistatus->doc); + g_free (multistatus->path); } static void @@ -772,6 +779,9 @@ multistatus_get_response (xmlNodeIter *resp_iter, MsResponse *response) xmlNodePtr iter; xmlNodePtr href; xmlNodePtr propstat; + SoupURI *uri; + const char *text; + char *path; multistatus = xml_node_iter_get_user_data (resp_iter); resp_node = xml_node_iter_get_current (resp_iter); @@ -805,48 +815,37 @@ multistatus_get_response (xmlNodeIter *resp_iter, MsResponse *response) if (href == NULL) return FALSE; - response->href = href; + text = node_get_content (href); + + if (text == NULL) + return FALSE; + + uri = soup_uri_new_with_base (multistatus->target, text); + + if (uri == NULL) + return FALSE; + + path = g_uri_unescape_string (uri->path, "/"); + soup_uri_free (uri); + + response->path = path; + response->is_target = path_equal (path, multistatus->path, TRUE); response->multistatus = multistatus; response->first_propstat = propstat; return resp_node != NULL; } -static char * -ms_response_get_basename (MsResponse *response) +static void +ms_response_clear (MsResponse *response) { - const char *text; - text = node_get_content (response->href); - - return http_uri_get_basename (text); - + g_free (response->path); } -static gboolean -ms_response_is_target (MsResponse *response) +static char * +ms_response_get_basename (MsResponse *response) { - const char *text; - SoupURI *target; - SoupURI *uri; - gboolean res; - - uri = NULL; - target = response->multistatus->target; - text = node_get_content (response->href); - - if (text == NULL) - return FALSE; - - uri = soup_uri_new_with_base (target, text); - - if (uri == NULL) - return FALSE; - - res = dav_uri_match (uri, target, TRUE); - - soup_uri_free (uri); - - return res; + return http_path_get_basename (response->path); } static void @@ -1248,13 +1247,15 @@ stat_location_finish (SoupMessage *msg, if (! multistatus_get_response (&iter, &response)) continue; - if (ms_response_is_target (&response)) + if (response.is_target) { file_type = ms_response_to_file_type (&response); res = TRUE; } else child_count++; + + ms_response_clear (&response); } if (res) @@ -1914,11 +1915,13 @@ do_query_info (GVfsBackend *backend, if (! multistatus_get_response (&iter, &response)) continue; - if (ms_response_is_target (&response)) + if (response.is_target) { ms_response_to_file_info (&response, job->file_info); res = TRUE; } + + ms_response_clear (&response); } multistatus_free (&ms); @@ -1987,12 +1990,14 @@ do_enumerate (GVfsBackend *backend, if (! multistatus_get_response (&iter, &response)) continue; - if (ms_response_is_target (&response)) - continue; + if (response.is_target == FALSE) + { + info = g_file_info_new (); + ms_response_to_file_info (&response, info); + g_vfs_job_enumerate_add_info (job, info); + } - info = g_file_info_new (); - ms_response_to_file_info (&response, info); - g_vfs_job_enumerate_add_info (job, info); + ms_response_clear (&response); } multistatus_free (&ms); |