diff options
author | Ross Lagerwall <rosslagerwall@gmail.com> | 2014-07-30 17:34:48 +0100 |
---|---|---|
committer | Ross Lagerwall <rosslagerwall@gmail.com> | 2014-09-27 09:37:24 +0100 |
commit | c6200ea2184b63016fe573155b0480ba88069456 (patch) | |
tree | 51a482187bacb3e1f3318ed9390190901dad7066 /daemon/gvfsafpconnection.c | |
parent | fab432937b4bfcd56c07c8be3e14335612bd42f3 (diff) | |
download | gvfs-c6200ea2184b63016fe573155b0480ba88069456.tar.gz |
afp: Use UTF-8 for volume names
Use UTF-8 for volume names since volume names are encoded as UTF-8 for
protocol versions 3.0 and higher. This prevents seeing volume names
like: "John’s Public Folder"
Since the volume name comes as a pascal string with UTF-8 encoding,
extend the function to read pascal strings with the ability to read
pascal strings encoded as UTF-8.
https://bugzilla.gnome.org/show_bug.cgi?id=733996
Diffstat (limited to 'daemon/gvfsafpconnection.c')
-rw-r--r-- | daemon/gvfsafpconnection.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/daemon/gvfsafpconnection.c b/daemon/gvfsafpconnection.c index 97d1f538..2f2958d7 100644 --- a/daemon/gvfsafpconnection.c +++ b/daemon/gvfsafpconnection.c @@ -275,7 +275,7 @@ g_vfs_afp_reply_dup_data (GVfsAfpReply *reply, gsize size, guint8 **data) } gboolean -g_vfs_afp_reply_read_pascal (GVfsAfpReply *reply, char **str) +g_vfs_afp_reply_read_pascal (GVfsAfpReply *reply, gboolean is_utf8, char **str) { guint8 strsize; @@ -290,12 +290,30 @@ g_vfs_afp_reply_read_pascal (GVfsAfpReply *reply, char **str) if (str) { - *str = g_convert (reply->data + reply->pos, strsize, - "UTF-8", "MACINTOSH", NULL, NULL, NULL); + if (is_utf8) + { + char *tmp; + + if (!g_vfs_afp_reply_get_data (reply, strsize, (guint8 **)&tmp)) + { + reply->pos--; + return FALSE; + } + + *str = g_utf8_normalize (tmp, strsize, G_NORMALIZE_DEFAULT_COMPOSE); + } + else + { + *str = g_convert (reply->data + reply->pos, strsize, + "UTF-8", "MACINTOSH", NULL, NULL, NULL); + reply->pos += strsize; + } + } + else + { + reply->pos += strsize; } - reply->pos += strsize; - return TRUE; } |