evanmiller/mod_zip — pull request #14 by devgs (2012-04-12 13:34:25+00:00)
Title: Workaround for a problem of irreversible filename conversions

Annotation:

Sometimes there might be a problem converting UTF-8 to zips native
charset(CP866), because it's not 1:1 conversion. So my solution is to
allow
developers provide their own version of converted filename and pass it
to mod_zip along with UTF-8 filename which will go straight to Unicode
path extra field (thanks to tony2001). So separator is a solution that
doesn't
break current format. And allows passing file name in both formats as
one string.

Normally we pass:
CRC32 \n
...
* passed to archive as filename w/o conversion
* UFT-8 flag for filename is set

tony2001's X-Archive-Charset: way:
CRC32 \n
...
* is accepted to be UTF-8 string
* , converted to and passed to archive as filename
* passed to Unicode path extra field
* UFT-8 flag for filename is not set

My X-Archive-Name-Sep: solution:
CRC32 \n
...
* passed to archive as filename w/o conversion
* passed to Unicode path extra field
* UFT-8 flag for filename is not set

You just need to provide separator that won't interfere with file
names. I suggest using '/'
as it is ASCII character and forbidden on most (if not all) platforms
as a part of filename.

Empty separator string means no UTF-8 version provided. Usefull when we
need to pass only
names encoded in native charset. It's equal to 'X-Archive-Charset:
native;'.
Note: Currently it is impossible after '[PATCH] Support for UTF-8 file
names.'(4f61592)
because UFT-8 flag (zip_utf8_flag) is set default for templates.