[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-zile] 2.3.24; Canonicalisation of user home directory fails
From: |
Ulrich Mueller |
Subject: |
[Bug-zile] 2.3.24; Canonicalisation of user home directory fails |
Date: |
Wed, 10 Aug 2011 20:24:13 +0200 |
Hi,
The following bug in Zile 2.3.24 was found by Diego Pettenò:
Create a user foo with home directory /home/foo and create a file at
/home/foobar/baz .
Then as user foo, try C-x C-f /home/foobar/baz TAB and it will become
~/ar/baz .
The patch included below fixes the problem for me.
Ulrich
>From e85f2839cb5c79d18c3cda40280413c7a752a12b Mon Sep 17 00:00:00 2001
From: Ulrich Mueller <address@hidden>
Date: Wed, 10 Aug 2011 19:59:19 +0200
Subject: [PATCH] Fix recognition of user directories in compact_path.
---
src/file.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/file.c b/src/file.c
index 366377b..2972ecb 100644
--- a/src/file.c
+++ b/src/file.c
@@ -168,14 +168,15 @@ compact_path (astr path)
{
/* Replace `/userhome/' (if found) with `~/'. */
size_t homelen = strlen (pw->pw_dir);
- if (astr_len (path) >= homelen &&
- !strncmp (pw->pw_dir, astr_cstr (path), homelen))
+ if (homelen > 0 && pw->pw_dir[homelen - 1] == '/')
+ homelen--;
+
+ if (astr_len (path) > homelen &&
+ !strncmp (pw->pw_dir, astr_cstr (path), homelen) &&
+ astr_get (path, homelen) == '/')
{
astr buf = astr_new_cstr ("~/");
- if (STREQ (pw->pw_dir, "/"))
- astr_cat_cstr (buf, astr_cstr (path) + 1);
- else
- astr_cat_cstr (buf, astr_cstr (path) + homelen + 1);
+ astr_cat_cstr (buf, astr_cstr (path) + homelen + 1);
astr_cpy (path, buf);
}
}
--
1.7.6
- [Bug-zile] 2.3.24; Canonicalisation of user home directory fails,
Ulrich Mueller <=