Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6739892
Votes 0
Synopsis Improve handling of zip encoding through use of property flag
Category java:classes_util_jarzip
Reported Against
Release Fixed , 1.4.2_21-rev(b04) (Bug ID:2170107)
State 11-Closed, Will Not Fix, request for enhancement
Priority: 3-Medium
Related Bugs 6823784 , 4244499
Submit Date 21-AUG-2008
Description
Dear all,

This RFE / defect is concerning a functionality reported by  customer  in their internal issue tracking system. The issue is attached to this report for your analysis and I'm just expecting whether this is a functionality that could be built into the JDK 1.4.2 considering the EOL in Septermber. I'm simply expecting a Go or No-Go evaluation that I could report to  customer . 

Thank you very much.

Here is the snippet from  customer  :


There are problems with ZIP handling of files with non-UTF8 encoded
file names.
See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4244499.

In order to improve the situation without changing existing APIs
 customer  has implemented following solution for java.util.zip.ZipInputStream
into SAPJVM 5.1 and suggests that SUN should think about a similar
approach for JDK 1.4.2, because we were faced with customer problems on
this version:

A new System Property called com. customer .jvm.ZipEntry.encoding was added
with the following behavior:

 not set: Reading ZIP files with entries with non-UTF8 chars will fail
          with IllegalArgumentException as before this change, but with

          a useful message pointing to the cause of the problem and
          the new System Property
 "default": If decoding an entry name with UTF8 fails, try the
            platform's default encoding. Reading ZIP files will succeed,
            but filenames might be wrong
 <encoding>: If decoding an entry name with UTF8 fails, try the given
             encoding. If the right encoding is given, reading the ZIP
             file will succeed and entry names will be converted
             correctly. WinRar and WinZip seem to use "Cp437" encoding.

The piece of code looks like this:

 Replace

   ZipEntry e = createZipEntry(getUTF8String(b, 0, len));

 by

   // SAPJVM SS 2008-07- customer  implemented workaround to be able to use
   // non-UTF8 encoded zip entry names
   String filename = null;
   try {
       // First try getUTF8String for compatibility
       filename = getUTF8String(b, 0, len);
   }
   catch (IllegalArgumentException e) {
       // UTF8 decoding failed!
       // alternative encoding requested?
       String encoding = System.getProperty("com. customer .jvm.ZipEntry.
encoding");
       if (encoding == null) {
           // no alternative encoding requested, just throw the
           // Exception (for compatibility), but add a message
           IllegalArgumentException ee = new IllegalArgumentException(
                   "zip entry name contained non-utf8 chars, try system
property " +
                   "com. customer .jvm.ZipEntry.encoding");
           ee.setStackTrace(e.getStackTrace());
           throw ee;
       }
       // an alternative encoding is requested
       if (encoding.equalsIgnoreCase("default")) {
           // use platform's default encoding

           filename = new String(b, 0, len);
       }
       else {
           // use the specified encoding
           // (WinZip and WinRar seem to use Cp437 )
           filename = new  String(b, 0, len, encoding);
       }
   }
   ZipEntry e = createZipEntry(filename);

Please check whether you could enter such a solution into JDK 1.4.2.
Posted Date : 2008-08-21 14:14:49.0
Work Around
N/A
Evaluation
Will implement changes close to what's been suggested. CCC approval necessary
Posted Date : 2008-11-27 12:41:33.0

new APIs have been added in JDK7 to address this particular issue. See#4244499. Closed the 7 MR.
Posted Date : 2009-05-20 01:20:58.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang