[TC 7.56a] Internal ZIP packer corrupts Silverlight packages

Please report only one bug per message!

Moderators: white, Hacker, petermad, Stefan2

Post Reply
Gene
Junior Member
Junior Member
Posts: 4
Joined: 2012-05-31, 06:41 UTC

[TC 7.56a] Internal ZIP packer corrupts Silverlight packages

Post by *Gene »

I often use Total Commander to modify the contents of a Silverlight XAP file, which is technically a ZIP file. Therefore, I navigate to the XAP file location in the left window and open the XAP with CTRL + Right in the right window. Then I double-click the file to modify and select Unpack and execute. After the modification have been done, I close my editor and Total Commander allows me to reintegrate the modified file into the XAP package.

If a XAP file containing sub-directories (for example localization resource folders) is modified with Total Commander, Silverlight will no longer be able to load this file.

0.png

In Fiddler you can easily see, that Silverlight tries to fetch the assemblies located in the sub-directory via HTTP from the web server:

1.png

Comparing the file generated with Visual Studio it seems, that Total Commander uses back slashes (\) to seperate single directories in the ZIP file, whereas Visual Studio (as well as the Windows Explorer, WinRAR and several others) use slashes (/).

2.png

I don't know what the ZIP specification requires as a directory seperation character, and whether this is a bug in Total Commander or in Visual Studio/Windows Explorer/WinRAR/... (or even in Silverlight) .

XAP file generated with Visual Studio: TestApplication_VS.xap
XAP file generated with Total Commander: TestApplication_TC.xap

Silverlight test project: TestApplication.zip

Thanks for your efforts.

P.S.: I'm sorry that I can't post URLs correctly here due to the spam protection. Base URL for all files is d l . d r o p b o x . c o m /u/36632473/TotalCommander/
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I don't know what specifications are used by Silverlight, but for example Android .apk files aren't just normal ZIP files: They require that some files inside the .apk are stored, not compressed. I guess that Silverlight uses some similar limitations, so it cannot handle all standard ZIP files.
Author of Total Commander
https://www.ghisler.com
Gene
Junior Member
Junior Member
Posts: 4
Joined: 2012-05-31, 06:41 UTC

Post by *Gene »

According to the Silverlight spec it's a plain ZIP file, compressed or not. It certainly has to contain some special files (for example the manifest), but that's not the problem here. The main difference between the output generated by TC and that from other packers is the reversed slash. The latest ZIP file format specification (pkware . c o m /documents/casestudies/APPNOTE.TXT) states in section J:
The name of the file, with optional relative path.
The path stored should not contain a drive or
device letter, or a leading slash. All slashes
should be forward slashes '/'
as opposed to
backwards slashes '\' for compatibility with Amiga
and UNIX file systems etc.
Sure, this is a "should" instead of a "must" here, but all other packers I know behave this way.

Thanks for your fast response and your time.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

???
TC does store paths with forward slashes in ZIP files.
Author of Total Commander
https://www.ghisler.com
Gene
Junior Member
Junior Member
Posts: 4
Joined: 2012-05-31, 06:41 UTC

Post by *Gene »

My version doesn't, see http://dl.dropbox.com/u/36632473/TotalCommander/2.png on the left side or download and compare the XAP files.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Strange, maybe the silverlight file contained them with backslashes? I just tried with TC8, it always creates them with forward slashes.
Author of Total Commander
https://www.ghisler.com
Gene
Junior Member
Junior Member
Posts: 4
Joined: 2012-05-31, 06:41 UTC

Post by *Gene »

I tested TC8 and the generated ZIP contains forward slashes (and can therefore be loaded by Silverlight). Strange, because I thought I tested this before.

Edit: Okay, I got a case where TC 8 replaced the original forward slash with a backslash (not in the directory at the end, but directly before the content of the file), causing Silverlight to crash again. I tried to reproduce this case with a simple ZIP archive with sub directories and text files, but had no luck yet.

If I completely generate a new archive with the extracted content of the XAP using WinRAR, the error doesn't seem to occur (so it seems to be related to Silverlight as you suggested). Therefore, as a workaround, I think I will change my build process to re-zip the XAP.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Please let me know if you find a way to reproduce this problem (backslashes stored in path). I have tried it with edting and re-packing, but couldn't find a situation where that happens.
Author of Total Commander
https://www.ghisler.com
Post Reply