Skip to content

Commit 3bff7dc

Browse files
Merge pull request #42 from ChristianSchulte/master
No need to fallback to unicode path extra field policy NOT_ENCODEABLE.
2 parents a2cb2e1 + 8015cc4 commit 3bff7dc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/java/org/codehaus/plexus/archiver/zip/AbstractZipArchiver.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ private void createArchiveMain()
342342
/**
343343
* Gets the {@code UnicodeExtraFieldPolicy} to apply.
344344
*
345-
* @return {@link ZipArchiveOutputStream.UnicodeExtraFieldPolicy.NOT_ENCODEABLE}, if the effective encoding is
345+
* @return {@link ZipArchiveOutputStream.UnicodeExtraFieldPolicy.NEVER}, if the effective encoding is
346346
* UTF-8; {@link ZipArchiveOutputStream.UnicodeExtraFieldPolicy.ALWAYS}, if the effective encoding is not
347347
* UTF-8.
348348
*
@@ -372,8 +372,12 @@ private ZipArchiveOutputStream.UnicodeExtraFieldPolicy getUnicodeExtraFieldPolic
372372
}
373373
}
374374

375+
// Using ZipArchiveOutputStream.UnicodeExtraFieldPolicy.NOT_ENCODEABLE as a fallback makes no sense here.
376+
// If the encoding is UTF-8 and a name is not encodeable using UTF-8, the Info-ZIP Unicode Path extra field
377+
// is not encodeable as well. If the effective encoding is not UTF-8, we always add the extra field. If it is
378+
// UTF-8, we never add the extra field.
375379
return utf8
376-
? ZipArchiveOutputStream.UnicodeExtraFieldPolicy.NOT_ENCODEABLE
380+
? ZipArchiveOutputStream.UnicodeExtraFieldPolicy.NEVER
377381
: ZipArchiveOutputStream.UnicodeExtraFieldPolicy.ALWAYS;
378382

379383
}

0 commit comments

Comments
 (0)