[gvfs] dav: Unescape URIs before comparing them for equality
- From: Ross Lagerwall <rossl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] dav: Unescape URIs before comparing them for equality
- Date: Sat, 29 Mar 2014 13:41:26 +0000 (UTC)
commit 50af53dad6c6d6df4ba03ac04a6c6c76d2ba2337
Author: Ross Lagerwall <rosslagerwall gmail com>
Date: Sun Mar 16 16:09:39 2014 +0000
dav: Unescape URIs before comparing them for equality
In some instances (e.g. Apache), gvfs uses percent encodings like %2A
while Apache returns redirections encoded like %2a. This makes
redirections fail when non-ascii characters are used in the path.
https://bugzilla.gnome.org/show_bug.cgi?id=721543
daemon/gvfsbackenddav.c | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/daemon/gvfsbackenddav.c b/daemon/gvfsbackenddav.c
index b75ddff..8c92d18 100644
--- a/daemon/gvfsbackenddav.c
+++ b/daemon/gvfsbackenddav.c
@@ -229,6 +229,7 @@ path_equal (const char *a, const char *b, gboolean relax)
{
gboolean res;
size_t a_len, b_len;
+ char *ua, *ub;
if (relax == FALSE)
return str_equal (a, b, FALSE);
@@ -236,20 +237,26 @@ path_equal (const char *a, const char *b, gboolean relax)
if (a == NULL || b == NULL)
return a == b;
- a_len = strlen (a);
- b_len = strlen (b);
+ ua = g_uri_unescape_string (a, "/");
+ ub = g_uri_unescape_string (b, "/");
- while (a_len > 0 && a[a_len - 1] == '/')
+ a_len = strlen (ua);
+ b_len = strlen (ub);
+
+ while (a_len > 0 && ua[a_len - 1] == '/')
a_len--;
- while (b_len > 0 && b[b_len - 1] == '/')
+ while (b_len > 0 && ub[b_len - 1] == '/')
b_len--;
if (a_len == b_len)
- res = ! strncmp (a, b, a_len);
+ res = ! strncmp (ua, ub, a_len);
else
res = FALSE;
+ g_free(ua);
+ g_free(ub);
+
return res;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]