-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with archives.Identify
when filename contains a compression extension
#7
Comments
The current implementation of the filename matching logic in // match filename
if strings.Contains(strings.ToLower(filename), gz.Name()) {
mr.ByName = true
} Maybe we should split the filename by // match filename
for _, w := range strings.Split(filename, ".")[1:]{
if strings.EqualFold(gz.Name(), "."+w){
mr.ByName = true
break
}
} Or provide a strict mode that matches only using the file header. |
Well, maybe we need to start with test cases then. Is What is Anyway, I agree we could improve this logic, but I am not sure what the answers are yet. Identify(), and thus Match(), are used to determine how to read files... typically they expect an outer compression layer, if any, and then an archive format if there's a second match, within the compressed layer (if any). So maybe the answer is a combination of chopping off a file extension after matching it, before matching the inner layer, or something like that; and making the filename matching more strict. |
If each time only the outermost layer of the compression or archive format is processed during decompression, can this problem be better addressed? |
That's basically how it works already. Anything that gets read from the archive is first decompressed. Reading headers is preferred, but sometimes only a filename is available. |
Title: Issue with
archives.Identify
when filename contains a compression extensionDescription:
I encountered an issue while using the
archives.Identify
function from thejackfan.us.kg/mholt/archives
package. When the file name includes a compression extension (e.g.,test.gzero.zip
), the function returns an error:gzip: invalid header
.Here is the code snippet to reproduce the issue:
Steps to Reproduce:
os.Open
.test.gzero.zip
) toarchives.Identify
.gzip: invalid header
).The text was updated successfully, but these errors were encountered: