diff --git a/daemon/gvfsbackendftp.c b/daemon/gvfsbackendftp.c
index 99aaef8..0e01f5d 100644
--- a/daemon/gvfsbackendftp.c
+++ b/daemon/gvfsbackendftp.c
@@ -196,21 +196,18 @@ g_vfs_backend_create_file_from_reply (GVfsBackendFtp *ftp, const char *name)
 {
   const char *end;
 
-  end = name + strlen (name);
-
   /* strip leading spaces */
   while (g_ascii_isspace (*name))
     name++;
 
-  /* strip leading and trailing quote character */
+  /* strip leading quote character */
   /* FIXME: need to unescape th contained string? */
-  if (*name == '"' && end[-1] == '"')
-    {
-      name++;
-      end--;
-    }
+  if (*name == '"')
+    name++;
+
+  end = strchr (name, '"');
 
-  if (*end == '\0') {
+  if (*end == NULL) {
     return g_vfs_ftp_file_new_from_ftp (ftp, name);
   } else {
     char *s = g_strndup (name, end - name);
