Thank you for the directions! But this was just the first bit of the 
problem...
I changed locally the archive/zip sources, making it accept both magic 
sequences on fileHeaderSignature and directoryHeaderSignature. Then I ran 
in UnexpectedEOF trap!
I think that there is some version/flavor of the zip format that is just 
unsupported by the archive/zip package (but is supported by the zip command 
line).
I am using Go1.8.3, I will try to upgrade to current (1.9.2) version. The 
release notes mention the zip package but only for the Writer type. Anyway 
I should upgrade sooner or later...

Cheers

Em quinta-feira, 9 de novembro de 2017 11:39:24 UTC-2, Tamás Gulácsi 
escreveu:
>
>
> 2017. november 9., csütörtök 14:11:13 UTC+1 időpontban Luis Furquim a 
> következőt írta:
>>
>> Hello Gophers!
>>
>> I am trying to open a chrome extension file to read its manifest.json. It 
>> is a zip file with a .crx extension. When I unzip via command line it works 
>> like a charm. But, if I try with golang using package archive/zip it gives 
>> me the "zip: not a valid zip file" error. It's not the first time I use 
>> this package and it always worked fine, including working with Libre Office 
>> documents (.odt). I checked with the "file" command and with "od -c | head" 
>> commands and realized that the Chrome Extensions files differ in the magic 
>> bytes:
>>
>> The regular zip file:
>> vuco@azrael ~/Documents $ od -c ./root/prms-minuano.zip | head -n 1 
>> 0000000 P K 003 004 024 \0 \0 \0 \b \0 016 210 0 @ 034 255 vuco@azrael 
>> ~/Documents $ file ./root/prms-minuano.zip ./root/prms-minuano.zip: Zip 
>> archive data, at least v2.0 to extract 
>>
>>
>> The odt file:
>> vuco@azrael ~/Documents $ od -c ./mpf/v1.ProjetoIntegracao.odt | head -n 
>> 1 0000000 P K 003 004 024 \0 \0 \b \0 \0 256 y 026 ? ^ 306 vuco@azrael 
>> ~/Documents $ file ./mpf/v1.ProjetoIntegracao.odt 
>> ./mpf/v1.ProjetoIntegracao.odt: OpenDocument Text 
>>
>>
>> The crx file:
>> sherlock@asspadev ~/work/download $ od -c lestrade.crx | head -n 1
>> 0000000 C r 2 4 002 \0 \0 \0 & 001 \0 \0 \0 001 \0 \0 
>> sherlock@asspadev ~/work/download $ file lestrade.crx lestrade.crx: data 
>>
>>
>> Any suggestions on how to open the file?
>>
>> Thank you in advance
>> Luis Otavio de Colla Furquim
>>
>>
> As "CRX files are ZIP files with a special header and the .crx file 
> extension. ", and ZIP has a "PK\x05\x06" magic sequence, 
> a working solution is to read all the bytes of the .crx into a []byte, 
> change the "Cr24" to "PK\x05\x06",
> then use a bytes.NewBuffer(b) as a ReaderAt.
>
> The problem is that this signature is in every block.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to