From 8015cc47d81a65af3f19f3f1dc07632351b33f52 Mon Sep 17 00:00:00 2001 From: Christian Schulte Date: Fri, 27 May 2016 00:51:31 +0200 Subject: [PATCH] Updated to stop falling back to the unicode path extra field policy NOT_ENCODEABLE. If a name is not encodeable in UTF-8, it also is not encodeable in the extra field. This closes #39 --- .../codehaus/plexus/archiver/zip/AbstractZipArchiver.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/codehaus/plexus/archiver/zip/AbstractZipArchiver.java b/src/main/java/org/codehaus/plexus/archiver/zip/AbstractZipArchiver.java index f18c88db5..98ed6ad89 100755 --- a/src/main/java/org/codehaus/plexus/archiver/zip/AbstractZipArchiver.java +++ b/src/main/java/org/codehaus/plexus/archiver/zip/AbstractZipArchiver.java @@ -342,7 +342,7 @@ private void createArchiveMain() /** * Gets the {@code UnicodeExtraFieldPolicy} to apply. * - * @return {@link ZipArchiveOutputStream.UnicodeExtraFieldPolicy.NOT_ENCODEABLE}, if the effective encoding is + * @return {@link ZipArchiveOutputStream.UnicodeExtraFieldPolicy.NEVER}, if the effective encoding is * UTF-8; {@link ZipArchiveOutputStream.UnicodeExtraFieldPolicy.ALWAYS}, if the effective encoding is not * UTF-8. * @@ -372,8 +372,12 @@ private ZipArchiveOutputStream.UnicodeExtraFieldPolicy getUnicodeExtraFieldPolic } } + // Using ZipArchiveOutputStream.UnicodeExtraFieldPolicy.NOT_ENCODEABLE as a fallback makes no sense here. + // If the encoding is UTF-8 and a name is not encodeable using UTF-8, the Info-ZIP Unicode Path extra field + // is not encodeable as well. If the effective encoding is not UTF-8, we always add the extra field. If it is + // UTF-8, we never add the extra field. return utf8 - ? ZipArchiveOutputStream.UnicodeExtraFieldPolicy.NOT_ENCODEABLE + ? ZipArchiveOutputStream.UnicodeExtraFieldPolicy.NEVER : ZipArchiveOutputStream.UnicodeExtraFieldPolicy.ALWAYS; }