--- gvfs-1.4.3.orig/daemon/gvfsbackenddav.c 2012-07-10 09:11:58.500910292 +0200 +++ gvfs-1.4.3/daemon/gvfsbackenddav.c 2012-07-10 11:26:11.048109676 +0200 @@ -620,15 +620,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 { @@ -644,17 +646,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; } @@ -663,6 +669,7 @@ static void multistatus_free (Multistatus *multistatus) { xmlFreeDoc (multistatus->doc); + g_free (multistatus->path); } static void @@ -683,6 +690,9 @@ multistatus_get_response (xmlNodeIter *r 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); @@ -716,54 +726,38 @@ multistatus_get_response (xmlNodeIter *r 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; - const char *path; - SoupURI *target; - SoupURI *uri; - gboolean res; - - uri = NULL; - path = NULL; - target = response->multistatus->target; - text = node_get_content (response->href); + return http_path_get_basename (response->path); - if (text == NULL) - return FALSE; - - uri = soup_uri_new_with_base (target, text); - - if (uri == NULL) - return FALSE; - - if (!uri->user) - soup_uri_set_user (uri, target->user); - if (!uri->password) - soup_uri_set_password (uri, target->password); - res = dav_uri_match (uri, target, TRUE); - - soup_uri_free (uri); - - return res; } static void @@ -1167,13 +1161,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) @@ -1833,11 +1829,13 @@ do_query_info (GVfsBackend *ba 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); @@ -1906,12 +1904,14 @@ do_enumerate (GVfsBackend *bac 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);