You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AbstractArchiver.getFiles returns platform-specific separators (for ZIP files) #129
The ZIP file spec says that only forward slashes should be used in entry names (https://stackoverflow.com/a/44387973) but in fact adding a directory on Windows with ZipArchiver.addFileSet(...) will lead to backslashes in the entry names returned by AbstractArchiver.getFiles().
This happens with plexus archiver 4.2.1.
Ok, the issue was that the check was performed on AbstractArchiver.getFiles() where the file name normalization has not happened yet. I wonder whether that is expected behaviour though. IMHO AbstractArchiver.getFiles() should already return the normalized names as keys.
Sorry but I'm not quite sure if there is a bug in Plexus Archiver or you made it work? If you believe there is a bug would you please share a code snipped that reproduces the issue? I ran one of the tests on Windows and it looks like the resulting ZIP archive is with / as file path separator.
As for AbstractArchiver.getFiles() - it is common for all acrhivers so it also makes sense not to normalized the names and let the concrete implementation decide if such normalization is needed. Although I not quite sure if there is any benefit from storing the Windows separator in the archived file name even if the archive format supports it.
@plamentotev Indeed the generated ZIP file is correct (i.e. only contains forward slashes). It is just AbstractArchiver.getFiles() which behaves unexpectedly. I would expect the entry names as they appear in the Zip. If in case of all other archivers there is no normalization necessary you would probably need to overwrite that method only for ZipArchiver. In any case it would be very helpful if the javadoc for getFiles would be extended with regards to the file name format which could be expected here.
changed the title [-]AbstractArchiver.addFileSet adds platform-specific separators[/-][+]AbstractArchiver.getFiles returns platform-specific separators (for ZIP files)[/+]on Nov 23, 2019
Yes, good point. Actually getFiles does not have any documentation at all. I might give it a try when I have more time. Contributions are welcome as well :)
Activity
kwin commentedon Nov 16, 2019
For the actual ZIP generation the normalization is done by
plexus-archiver/src/main/java/org/codehaus/plexus/archiver/zip/AbstractZipArchiver.java
Line 370 in b9ea3bf
getFiles()though.kwin commentedon Nov 16, 2019
Ok, the issue was that the check was performed on
AbstractArchiver.getFiles()where the file name normalization has not happened yet. I wonder whether that is expected behaviour though. IMHOAbstractArchiver.getFiles()should already return the normalized names as keys.plamentotev commentedon Nov 21, 2019
Hi,
Sorry but I'm not quite sure if there is a bug in Plexus Archiver or you made it work? If you believe there is a bug would you please share a code snipped that reproduces the issue? I ran one of the tests on Windows and it looks like the resulting ZIP archive is with
/as file path separator.As for
AbstractArchiver.getFiles()- it is common for all acrhivers so it also makes sense not to normalized the names and let the concrete implementation decide if such normalization is needed. Although I not quite sure if there is any benefit from storing the Windows separator in the archived file name even if the archive format supports it.kwin commentedon Nov 23, 2019
@plamentotev Indeed the generated ZIP file is correct (i.e. only contains forward slashes). It is just
AbstractArchiver.getFiles()which behaves unexpectedly. I would expect the entry names as they appear in the Zip. If in case of all other archivers there is no normalization necessary you would probably need to overwrite that method only forZipArchiver. In any case it would be very helpful if the javadoc forgetFileswould be extended with regards to the file name format which could be expected here.[-]AbstractArchiver.addFileSet adds platform-specific separators[/-][+]AbstractArchiver.getFiles returns platform-specific separators (for ZIP files)[/+]plamentotev commentedon Dec 27, 2019
Yes, good point. Actually
getFilesdoes not have any documentation at all. I might give it a try when I have more time. Contributions are welcome as well :)