AgileBits/objective-zip — pull request #6 by mz2 (2012-10-26 11:12:07+00:00)
Title: Fixed an sisue causing files with certain Unicode characters not be found from a ZipFile

There is a subtle issue in ZipFile.m with how the file contents dictionary is parsed for -initWithFileName:mode: and then queried in -locateFileInZip: . If -locateFileInZip: is called with a string that uses a different Unicode normalization form than what was used to encode the file names and used as the key in the contents dictionary, the file info object is not found (the ZipFile 'contents' dictionary would have its keys in a different Unicode normalisation form).

To give an example, here are two strings which look exactly similar to the eye but have different hash codes (and therefore different keys in an NSDictionary):

(gdb) print (NSUInteger)[@"Contents/Resources/N. Engl. J. Med. 2009 Hütter.pdf" hash]
$5 = 523423533613971934
(gdb) print (NSUInteger)[@"Contents/Resources/N. Engl. J. Med. 2009 Hütter.pdf" hash]
$6 = 13774458812937735516

In an error case I encountered, the string I received from another component in the application uses the 2nd kind of representation, whereas Objective-Zip the first kind. Requiring a certain Unicode normalization form as arguments given to -locateFileInZip: is not practical, therefore my suggested solution uses uses the Normalization Form D as the 'contents' dictionary keys (the file info 'name' strings), and converts the string given as an argument to -locateFileInZip: to this same form.