Feature request: Make file-roller more foolproof by checking for magic numbers instead of checking the file extension.
As you probably know, there are two ways to get the file type of a file: You can either check the file extension or check for magic numbers. In the Linux-world, checking for magic numbers is prefered, e.g. xdg-open and the file command ignore file extensions and read magic numbers. I also think checking for magic numbers is better, because non-techy users might accidentally change the file extension and programs that ignore the file extension allow you to remove the file extension, this makes the output of ls or the view of a filemanager look cleaner. However, file-roller can still be fooled by renaming the file. The following script consructs a valid example .gz , .tar and .tar.gz file, then renames it and tries to open it. You can see, that some combinations of original file extension and new file extension work, while some other fail. As explained above, I think, that everyone of the following file-roller commands should work.
echo "123" > file
gzip file
file-roller file.gz #works
cp file.gz file.zip
file-roller file.zip #An error occured while loading the archive.
cp file.gz file.tar
file-roller file.tar #An error occured while loading the archive.
cp file.gz file.tar.gz
file-roller file.tar.gz #An error occured while loading the archive.
cp file.gz file
file-roller file #Opening works, but extracting fails with the message: An error occured while extracting files.
echo "123" > file
tar cvzf file.tar.gz file
file-roller file.tar.gz #works
cp file.tar.gz file.tar
file-roller file.tar #works
cp file.tar.gz file
file-roller file #Opening works, but extracting fails with the message: An error occured while extracting files.
cp file.tar.gz file.zip
file-roller file.zip #An error occured while loading the archive.
cp file.tar.gz file.gz
file-roller file.gz #works (But if you open the inner file, you get the same error as after cp file.tar file)
echo "123" > file
tar cvf file.tar file
file-roller file.tar #works
cp file.tar file
file-roller file #Could not open "file": Archive type not supported.
cp file.tar file.zip
file-roller file.zip #An error occured while loading the archive.
cp file.tar file.gz
file-roller file.gz #An error occured while loading the archive.
cp file.tar file.tar.gz
file-roller file.tar.gz #works
echo "123" > file
zip arc file
file-roller arc.zip #works
cp arc.zip arc
file-roller arc #works
cp arc.zip arc.tar
file-roller arc.tar #Opening works, but extracting fails with the message: An error occured while extracting files.
cp arc.zip arc.gz
file-roller arc.gz #works
cp arc.zip arc.tar.gz
file-roller arc.tar.gz #Opening works, but extracting fails with the message: An error occured while extracting files.