Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 147018 Details for
Bug 225576
RFE: handle non-ascii filenames in archive properly
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
support for non-latin1 filenames in archive
unzip-5.52-iconv.patch (text/plain), 5.92 KB, created by
Dmitry Butskoy
on 2007-01-31 13:47:01 UTC
(
hide
)
Description:
support for non-latin1 filenames in archive
Filename:
MIME Type:
Creator:
Dmitry Butskoy
Created:
2007-01-31 13:47:01 UTC
Size:
5.92 KB
patch
obsolete
>diff -Nrbu unzip-5.52/fileio.c unzip-5.52-OK/fileio.c >--- unzip-5.52/fileio.c 2007-01-30 21:12:18.000000000 +0300 >+++ unzip-5.52-OK/fileio.c 2007-01-30 21:12:01.000000000 +0300 >@@ -2078,9 +2078,9 @@ > /* translate the text coded in the entry's host-dependent > "extended ASCII" charset into the compiler's (system's) > internal text code page */ >- Ext_ASCII_TO_Native((char *)G.outbuf, G.pInfo->hostnum, >- G.pInfo->hostver, G.pInfo->HasUxAtt, >- FALSE); >+ Ext_ASCII_TO_Native((char *)G.outbuf, OUTBUFSIZ, >+ G.pInfo->hostnum, G.pInfo->hostver, >+ G.pInfo->HasUxAtt, FALSE); > #ifdef WINDLL > /* translate to ANSI (RTL internal codepage may be OEM) */ > INTERN_TO_ISO((char *)G.outbuf, (char *)G.outbuf); >@@ -2160,7 +2160,8 @@ > > /* translate the Zip entry filename coded in host-dependent "extended > ASCII" into the compiler's (system's) internal text code page */ >- Ext_ASCII_TO_Native(G.filename, G.pInfo->hostnum, G.pInfo->hostver, >+ Ext_ASCII_TO_Native(G.filename, FILNAMSIZ, >+ G.pInfo->hostnum, G.pInfo->hostver, > G.pInfo->HasUxAtt, (option == DS_FN_L)); > > if (G.pInfo->lcflag) /* replace with lowercase filename */ >diff -Nrbu unzip-5.52/unix/unix.c unzip-5.52-OK/unix/unix.c >--- unzip-5.52/unix/unix.c 2007-01-30 21:12:18.000000000 +0300 >+++ unzip-5.52-OK/unix/unix.c 2007-01-30 21:14:36.000000000 +0300 >@@ -30,6 +30,10 @@ > #define UNZIP_INTERNAL > #include "unzip.h" > >+#include <locale.h> >+#include <iconv.h> >+#include <langinfo.h> >+ > #ifdef SCO_XENIX > # define SYSNDIR > #else /* SCO Unix, AIX, DNIX, TI SysV, Coherent 4.x, ... */ >@@ -1671,3 +1675,116 @@ > } > } > #endif /* QLZIP */ >+ >+ >+static struct { >+ const char *iso_name; >+ const char *cp_name; >+} enc_map[] = { >+ { "ISO-8859-1", "CP850" }, >+ { "ISO-8859-2", "CP852" }, >+ { "ISO-8859-5", "CP866" }, >+ { "ISO-8859-6", "CP864" }, >+ { "ISO-8859-7", "CP869" }, >+ { "ISO-8859-8", "CP862" }, >+ { "ISO-8859-9", "CP857" }, >+ { "TIS-620", "CP874" }, >+ { "EUC-JP", "CP932" }, >+ { "EUC-KR", "CP949" }, >+ { "GB2312", "CP936" }, >+ { "BIG5", "CP950" }, >+}; >+ >+static const char *from_enc = "CP850"; >+static const char *to_enc = "UTF-8"; >+ >+void init_encodings (void) { >+ const char *saved_locale, *non_utf8; >+ char *loc, *p; >+ int i; >+ >+ loc = getenv ("LC_ALL") ?: getenv ("LANG"); >+ if (!loc || !(loc = strdup (loc))) return; >+ >+ >+ /* save the locale anyway -- we don't know whether program >+ do setlocale() itself or not... >+ */ >+ saved_locale = setlocale (LC_ALL, NULL); >+ >+ setlocale (LC_ALL, ""); >+ to_enc = nl_langinfo (CODESET); >+ >+ /* The idea to obtain "from_enc" is: >+ Remove codeset part of LC_ALL/LANG (leave only language/country), >+ and see what charmap would be used. By this "non-utf8" charmap >+ we try to guess the correspond OEM/DOS codepage... >+ */ >+ p = strchr (loc, '.'); >+ if (p) *p = '\0'; >+ >+ /* temporary... */ >+ setlocale (LC_ALL, loc); >+ non_utf8 = nl_langinfo (CODESET); >+ >+ for (i = 0; i < sizeof (enc_map) / sizeof (*enc_map); i++) { >+ >+ if (!strcasecmp (non_utf8, enc_map[i].iso_name)) { >+ >+ from_enc = enc_map[i].cp_name; >+ >+ /* need some more work for latin1 ... */ >+ if (!strcmp (enc_map[i].iso_name, "ISO-8859-1")) { >+ char *lang = getenv ("LC_ALL") ?: getenv ("LANG"); >+ if (lang) { >+ if (!strncasecmp (lang, "da", 2) || >+ !strncasecmp (lang, "nb", 2) || >+ !strncasecmp (lang, "nn", 2) || >+ !strncasecmp (lang, "no", 2) >+ ) from_enc = "CP865"; >+ else if (!strncasecmp (lang, "is", 2)) >+ from_enc = "CP861"; >+ else if (!strncasecmp (lang, "lt", 2) || >+ !strncasecmp (lang, "lv", 2) >+ ) from_enc = "CP775"; >+ } >+ } >+ >+ break; >+ } >+ } >+ >+ setlocale (LC_ALL, saved_locale); >+ >+ return; >+} >+ >+void oem_to_local (char *str, size_t size) { >+ iconv_t conv; >+ size_t in_len, out_len; >+ char *out, *out_ptr, *in_ptr; >+ >+ >+ conv = iconv_open (to_enc, from_enc); >+ if (conv == (iconv_t) -1) return; /* foo on you */ >+ >+ in_len = strlen (str); >+ in_ptr = str; >+ >+ out_len = 4 * in_len + 1; /* assume enough even for utf8 ... */ >+ if (out_len > size) out_len = size; >+ out_len--; /* for terminating '\0' */ >+ out = out_ptr = alloca (out_len); >+ >+ if (iconv (conv, &in_ptr, &in_len, &out_ptr, &out_len) < 0) >+ return; /* foo on you */ >+ >+ out_len = (out_ptr - out); >+ if (out_len >= size) >+ return; /* paranoia */ >+ >+ memcpy (str, out, out_len); >+ str[out_len] = '\0'; >+ >+ return; >+} >diff -Nrbu unzip-5.52/unzip.c unzip-5.52-OK/unzip.c >--- unzip-5.52/unzip.c 2005-02-27 07:37:14.000000000 +0300 >+++ unzip-5.52-OK/unzip.c 2007-01-30 21:12:01.000000000 +0300 >@@ -668,6 +668,10 @@ > > SETLOCALE(LC_CTYPE,""); > >+#ifdef UNIX >+ init_encodings (); >+#endif >+ > #if (defined(__IBMC__) && defined(__DEBUG_ALLOC__)) > extern void DebugMalloc(void); > >diff -Nrbu unzip-5.52/unzpriv.h unzip-5.52-OK/unzpriv.h >--- unzip-5.52/unzpriv.h 2007-01-30 21:12:18.000000000 +0300 >+++ unzip-5.52-OK/unzpriv.h 2007-01-30 21:12:01.000000000 +0300 >@@ -2576,13 +2576,19 @@ > * All other ports are assumed to code zip entry filenames in ISO 8859-1. > */ > #ifndef Ext_ASCII_TO_Native >-# define Ext_ASCII_TO_Native(string, hostnum, hostver, isuxatt, islochdr) \ >+#ifndef UNIX >+#define _OEM_INTERN_SIZE(STR,SIZE) _OEM_INTERN((STR)) >+#else >+extern void oem_to_local (char *str, size_t size); >+#define _OEM_INTERN_SIZE(STR,SIZE) oem_to_local ((STR), (SIZE)) >+#endif >+# define Ext_ASCII_TO_Native(string, size, hostnum, hostver, isuxatt, islochdr) \ > if (((hostnum) == FS_FAT_ && \ > !(((islochdr) || (isuxatt)) && \ > ((hostver) == 25 || (hostver) == 26 || (hostver) == 40))) || \ > (hostnum) == FS_HPFS_ || \ > ((hostnum) == FS_NTFS_ && (hostver) == 50)) { \ >- _OEM_INTERN((string)); \ >+ _OEM_INTERN_SIZE((string),(size)); \ > } else { \ > _ISO_INTERN((string)); \ > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 225576
: 147018 |
157351
|
513838
|
515107
|
1033515
|
1097704
|
1097705
|
1097765
|
1097835
|
1098716
|
1098839