mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 12:56:51 +03:00
Ticket #4077: extfs: handle file names started with dash or space.
* (extfs_open_archive): skip leading ./ in file names. extfs plug-ins are added leading ./ to handle files with name started with space. * (extfs_cmd): skip leading ./ added in name_quote(). ./ is added to handle files with name started with dash. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
a2bccac622
commit
d3c8e5bad7
@ -373,6 +373,26 @@ extfs_free_archive (struct vfs_class *me, struct vfs_s_super *psup)
|
|||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
static inline char *
|
||||||
|
extfs_skip_leading_dotslash (char *s)
|
||||||
|
{
|
||||||
|
/* Skip leading "./" (if present).
|
||||||
|
* Some programs don't understand it:
|
||||||
|
*
|
||||||
|
* $ zip file.zip ./-file2.txt file1.txt
|
||||||
|
* adding: -file2.txt (stored 0%)
|
||||||
|
* adding: file1.txt (stored 0%)
|
||||||
|
* $ /usr/lib/mc/extfs.d/uzip copyout file.zip ./-file2.txt ./tmp-file2.txt
|
||||||
|
* caution: filename not matched: ./-file2.txt
|
||||||
|
*/
|
||||||
|
if (s[0] == '.' && s[1] == PATH_SEP)
|
||||||
|
s += 2;
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static FILE *
|
static FILE *
|
||||||
extfs_open_archive (int fstype, const char *name, struct extfs_super_t **pparc)
|
extfs_open_archive (int fstype, const char *name, struct extfs_super_t **pparc)
|
||||||
{
|
{
|
||||||
@ -486,6 +506,7 @@ extfs_read_archive (FILE * extfsd, struct extfs_super_t *current_archive)
|
|||||||
|
|
||||||
if (*cfn != '\0')
|
if (*cfn != '\0')
|
||||||
{
|
{
|
||||||
|
cfn = extfs_skip_leading_dotslash (cfn);
|
||||||
if (IS_PATH_SEP (*cfn))
|
if (IS_PATH_SEP (*cfn))
|
||||||
cfn++;
|
cfn++;
|
||||||
p = strchr (cfn, '\0');
|
p = strchr (cfn, '\0');
|
||||||
@ -812,13 +833,16 @@ extfs_cmd (const char *str_extfs_cmd, const struct extfs_super_t *archive,
|
|||||||
quoted_file = name_quote (file, FALSE);
|
quoted_file = name_quote (file, FALSE);
|
||||||
g_free (file);
|
g_free (file);
|
||||||
|
|
||||||
|
/* Skip leading "./" (if present) added in name_quote() */
|
||||||
|
file = extfs_skip_leading_dotslash (quoted_file);
|
||||||
|
|
||||||
archive_name = extfs_get_archive_name (archive);
|
archive_name = extfs_get_archive_name (archive);
|
||||||
quoted_archive_name = name_quote (archive_name, FALSE);
|
quoted_archive_name = name_quote (archive_name, FALSE);
|
||||||
g_free (archive_name);
|
g_free (archive_name);
|
||||||
quoted_localname = name_quote (localname, FALSE);
|
quoted_localname = name_quote (localname, FALSE);
|
||||||
info = &g_array_index (extfs_plugins, extfs_plugin_info_t, archive->fstype);
|
info = &g_array_index (extfs_plugins, extfs_plugin_info_t, archive->fstype);
|
||||||
cmd = g_strconcat (info->path, info->prefix, str_extfs_cmd,
|
cmd = g_strconcat (info->path, info->prefix, str_extfs_cmd,
|
||||||
quoted_archive_name, " ", quoted_file, " ", quoted_localname, (char *) NULL);
|
quoted_archive_name, " ", file, " ", quoted_localname, (char *) NULL);
|
||||||
g_free (quoted_file);
|
g_free (quoted_file);
|
||||||
g_free (quoted_localname);
|
g_free (quoted_localname);
|
||||||
g_free (quoted_archive_name);
|
g_free (quoted_archive_name);
|
||||||
|
Loading…
Reference in New Issue
Block a user