diff options
author | Tomas Bzatek <tbzatek@redhat.com> | 2011-03-17 17:45:29 +0100 |
---|---|---|
committer | Tomas Bzatek <tbzatek@redhat.com> | 2011-03-17 17:45:29 +0100 |
commit | 4a5d5e7f275496243e51f58415946c2186e757c4 (patch) | |
tree | 3c41723407ab0b2a3f49d32dbd59bb835597b065 /daemon/gvfsbackendarchive.c | |
parent | 1e92e6f3b2bbf581946825bca528b018cab3d9e7 (diff) | |
download | gvfs-4a5d5e7f275496243e51f58415946c2186e757c4.tar.gz |
archive: Skip leading "./" from pathnames if present
Happens with some archive types, such as rpm (libarchive 2.8.4).
Diffstat (limited to 'daemon/gvfsbackendarchive.c')
-rw-r--r-- | daemon/gvfsbackendarchive.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/daemon/gvfsbackendarchive.c b/daemon/gvfsbackendarchive.c index 50aa176c..c9ac573e 100644 --- a/daemon/gvfsbackendarchive.c +++ b/daemon/gvfsbackendarchive.c @@ -256,11 +256,16 @@ g_vfs_backend_archive_init (GVfsBackendArchive *archive) static ArchiveFile * archive_file_get_from_path (ArchiveFile *file, const char *filename, gboolean add) { - char **names = g_strsplit (filename, "/", -1); + char **names; ArchiveFile *cur; GSList *walk; guint i; + /* libarchive reports paths starting with ./ for some archive types */ + if (g_str_has_prefix (filename, "./")) + filename += 2; + names = g_strsplit (filename, "/", -1); + DEBUG ("%s %s\n", add ? "add" : "find", filename); for (i = 0; file && names[i] != NULL; i++) { @@ -626,6 +631,7 @@ do_open_for_read (GVfsBackend * backend, struct archive_entry *entry; int result; ArchiveFile *file; + const char *entry_pathname; file = archive_file_find (ba, filename); if (file == NULL) @@ -657,8 +663,12 @@ do_open_for_read (GVfsBackend * backend, archive_set_error (archive->archive, ARCHIVE_OK, "No error"); archive_clear_error (archive->archive); } - - if (g_str_equal (archive_entry_pathname (entry), filename + 1)) + + entry_pathname = archive_entry_pathname (entry); + /* skip leading garbage if present */ + if (g_str_has_prefix (entry_pathname, "./")) + entry_pathname += 2; + if (g_str_equal (entry_pathname, filename + 1)) { /* SUCCESS */ g_vfs_job_open_for_read_set_handle (job, archive); |