Author: bodewig
Date: Thu Mar 5 04:38:07 2009
New Revision: 750311
URL: http://svn.apache.org/viewvc?rev=750311&view=rev
Log:
ensure the same encoding is used for name and comment in all places. Submitted
by Wolfgang Glas
Modified:
ant/core/trunk/src/main/org/apache/tools/zip/ZipOutputStream.java
(contents, props changed)
Modified: ant/core/trunk/src/main/org/apache/tools/zip/ZipOutputStream.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/zip/ZipOutputStream.java?rev=750311&r1=750310&r2=750311&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/zip/ZipOutputStream.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/zip/ZipOutputStream.java Thu Mar
5 04:38:07 2009
@@ -682,12 +682,16 @@
protected void writeLocalFileHeader(ZipEntry ze) throws IOException {
boolean encodable = zipEncoding.canEncode(ze.getName());
- ByteBuffer name;
+
+ final ZipEncoding entryEncoding;
+
if (!encodable && fallbackToUTF8) {
- name = ZipEncodingHelper.UTF8_ZIP_ENCODING.encode(ze.getName());
+ entryEncoding = ZipEncodingHelper.UTF8_ZIP_ENCODING;
} else {
- name = zipEncoding.encode(ze.getName());
+ entryEncoding = zipEncoding;
}
+
+ ByteBuffer name = entryEncoding.encode(ze.getName());
if (createUnicodeExtraFields != UnicodeExtraFieldPolicy.NEVER) {
@@ -706,7 +710,7 @@
if (createUnicodeExtraFields == UnicodeExtraFieldPolicy.ALWAYS
|| !commentEncodable) {
- ByteBuffer commentB = this.zipEncoding.encode(comm);
+ ByteBuffer commentB = entryEncoding.encode(comm);
ze.addExtraField(new UnicodeCommentExtraField(comm,
commentB.array(),
commentB.arrayOffset(),
@@ -836,12 +840,16 @@
// CheckStyle:MagicNumber ON
// file name length
- ByteBuffer name;
+ final ZipEncoding entryEncoding;
+
if (!encodable && fallbackToUTF8) {
- name = ZipEncodingHelper.UTF8_ZIP_ENCODING.encode(ze.getName());
+ entryEncoding = ZipEncodingHelper.UTF8_ZIP_ENCODING;
} else {
- name = zipEncoding.encode(ze.getName());
+ entryEncoding = zipEncoding;
}
+
+ ByteBuffer name = entryEncoding.encode(ze.getName());
+
writeOut(ZipShort.getBytes(name.limit()));
written += SHORT;
@@ -855,12 +863,9 @@
if (comm == null) {
comm = "";
}
- ByteBuffer commentB;
- if (!encodable && fallbackToUTF8) {
- commentB = ZipEncodingHelper.UTF8_ZIP_ENCODING.encode(comm);
- } else {
- commentB = zipEncoding.encode(comm);
- }
+
+ ByteBuffer commentB = entryEncoding.encode(comm);
+
writeOut(ZipShort.getBytes(commentB.limit()));
written += SHORT;
Propchange: ant/core/trunk/src/main/org/apache/tools/zip/ZipOutputStream.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Mar 5 04:38:07 2009
@@ -1 +1 @@
-/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java:745920,747810,747841,748063,749342,749906-749907,750055
+/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java:745920,747810,747841,748063,749342,749906-749907,750055,750310