diff options
author | Ross Lagerwall <rosslagerwall@gmail.com> | 2014-03-16 16:09:39 +0000 |
---|---|---|
committer | Ross Lagerwall <rosslagerwall@gmail.com> | 2014-03-29 13:40:55 +0000 |
commit | 50af53dad6c6d6df4ba03ac04a6c6c76d2ba2337 (patch) | |
tree | 223de88327062603b8cc00bf368e019fcdc9e900 | |
parent | a77cdbac08ca1ff17aeba2323a610a61101387db (diff) | |
download | gvfs-50af53dad6c6d6df4ba03ac04a6c6c76d2ba2337.tar.gz |
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
-rw-r--r-- | daemon/gvfsbackenddav.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/daemon/gvfsbackenddav.c b/daemon/gvfsbackenddav.c index b75ddff6..8c92d180 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; } |