summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2019-03-22 14:34:02 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2019-03-22 14:34:02 (GMT)
commit963add27d0c6b4361d78c30a1b5a362e2c7355e6 (patch) (side-by-side diff)
treedb89887611ef6c55beb780bbe49558a844e8c7cf
parent43214185092e714e0c233bf196f571bba5c17be0 (diff)
downloadmailutils-963add27d0c6b4361d78c30a1b5a362e2c7355e6.tar.gz
mailutils-963add27d0c6b4361d78c30a1b5a362e2c7355e6.tar.bz2
Fix MH format detection
* libproto/mh/folder.c (mh_dir_p): Check only regular files. (_mh_list_p): Ditto. All directories are eligible for listing. * libmailutils/base/registrar.c (mu_record_list_p): Remove useless check.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libmailutils/base/registrar.c2
-rw-r--r--libproto/mh/folder.c23
2 files changed, 22 insertions, 3 deletions
diff --git a/libmailutils/base/registrar.c b/libmailutils/base/registrar.c
index e1d8a43..da736a0 100644
--- a/libmailutils/base/registrar.c
+++ b/libmailutils/base/registrar.c
@@ -342,8 +342,6 @@ mu_record_get_folder (mu_record_t record, int (*(*_pfolder)) (mu_folder_t))
int
mu_record_list_p (mu_record_t record, const char *name, int flags)
{
- if (record == NULL)
- return EINVAL;
return record == NULL
|| !record->_list_p
|| record->_list_p (record, name, flags);
diff --git a/libproto/mh/folder.c b/libproto/mh/folder.c
index dc45166..6c034b3 100644
--- a/libproto/mh/folder.c
+++ b/libproto/mh/folder.c
@@ -60,6 +60,24 @@ mh_dir_p (const char *name)
while (!result && (entry = readdir (dir)))
{
+ char *pname;
+ struct stat st;
+ int rc;
+
+ if (entry->d_name[0] == '.'
+ && (entry->d_name[1] == 0
+ || (entry->d_name[1] == '.' && entry->d_name[2] == 0)))
+ continue;
+
+ pname = mu_make_file_name (name, entry->d_name);
+ if (!pname)
+ continue;
+
+ rc = stat (pname, &st);
+ free (pname);
+ if (rc || !S_ISREG (st.st_mode))
+ continue;
+
switch (entry->d_name[0])
{
case '.':
@@ -119,13 +137,16 @@ _mh_is_scheme (mu_record_t record, mu_url_t url, int flags)
}
static int
-_mh_list_p (mu_record_t record, const char *name, int flags MU_ARG_UNUSED)
+_mh_list_p (mu_record_t record, const char *name, int flags)
{
if (name[0] == ',' ||
((strlen (name) > 3) &&
(memcmp (name, ".mh", 3) == 0 || memcmp (name, ".mu", 3) == 0)))
return 0;
+ if (flags == MU_FOLDER_ATTRIBUTE_DIRECTORY)
+ return 1;
+
for (; *name; name++)
if (!mu_isdigit (*name))
return 1;

Return to:

Send suggestions and report system problems to the System administrator.