diff options
author | A. Walton <awalton@gnome.org> | 2008-06-11 15:13:24 +0000 |
---|---|---|
committer | Andrew Walton <awalton@src.gnome.org> | 2008-06-11 15:13:24 +0000 |
commit | 7c294254e21706b26d955311e067c0e0ac1a87e4 (patch) | |
tree | 4609ec9e09fbc6b219879f195ddcf456f57ba963 /daemon | |
parent | bb81ac8dad7873ac3f6954644d9c0a0849781573 (diff) | |
download | gvfs-7c294254e21706b26d955311e067c0e0ac1a87e4.tar.gz |
Use hex escapes in the trash backend. Patch by Andreas Henriksson. Fixes
2008-06-11 A. Walton <awalton@gnome.org>
* daemon/gvfsbackendtrash.c (escape_pathname),
(unescape_pathname):
Use hex escapes in the trash backend.
Patch by Andreas Henriksson.
Fixes bug #523139.
svn path=/trunk/; revision=1805
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/gvfsbackendtrash.c | 49 |
1 files changed, 32 insertions, 17 deletions
diff --git a/daemon/gvfsbackendtrash.c b/daemon/gvfsbackendtrash.c index 39f93752..de12635d 100644 --- a/daemon/gvfsbackendtrash.c +++ b/daemon/gvfsbackendtrash.c @@ -147,17 +147,21 @@ escape_pathname (const char *dir) while (*dir == '/') dir++; - /* Underscores are doubled, count them */ + /* count characters that need to be escaped. */ count = 0; p = dir; while (*p) { if (*p == '_') count++; + if (*p == '/') + count++; + if (*p == '%') + count++; p++; } - res = g_malloc (strlen (dir) + count + 1); + res = g_malloc (strlen (dir) + count*2 + 1); p = dir; d = res; @@ -166,18 +170,27 @@ escape_pathname (const char *dir) c = *p++; if (c == '_') { - *d++ = '_'; - *d++ = '_'; + *d++ = '%'; + *d++ = '5'; + *d++ = 'f'; } else if (c == '/') { - *d++ = '_'; + *d++ = '%'; + *d++ = '2'; + *d++ = 'f'; /* Skip consecutive slashes, they are unnecessary, and break our escaping */ while (*p == '/') p++; } + else if (c == '%') + { + *d++ = '%'; + *d++ = '2'; + *d++ = '5'; + } else *d++ = c; } @@ -215,20 +228,22 @@ unescape_pathname (const char *escaped_dir, int len) while (p < end) { c = *p++; - if (c == '_') + if (c == '%' && p < (end-1)) { - if (p == end) - *d++ = '_'; - else + if (*(p) == '2' && *(p+1) == 'f') { - c = *p; - if (c == '_') - { - p++; - *d++ = '_'; - } - else - *d++ = '/'; + *d++ = '/'; + p+=2; + } + else if (*(p) == '2' && *(p+1) == '5') + { + *d++ = '%'; + p+=2; + } + else if (*(p) == '5' && *(p+1) == 'f') + { + *d++ = '_'; + p+=2; } } else |