Adv

4/18/2012

FIX: When you try to download a .doc file, it saved as .wiz

When someday you want to download a Word doc file from Internet, but your browser (IE9 or Chrome) saved / suggest you a file name in ".wiz" (but not always).  How come?

Stop blaming your browser, it is not their fault (at least, not all). It is because you have OFFICE STARTER installed.

If you just want to fix the problem, import the registry listed below. I explain detail follow.

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/msword]
@="Word.Word.8"
"Extension"=".doc"
"SoftGridSource"="{90140011-0066-0409-0000-0000000FF1CE}"

Backup your own registry before you apply the fix, I won't suggest it anyway. [If you know how to fix by the above little instruction, you won't need a backup :) ]

There is nothing wrong in the web server and the web browser, but the Windows 7 give unwanted data to Chrome(or IE).

There are some server system won't tell the browser the filename they are opening when it download a file.
Let's use the below HTTP request for example,

GET /somewhere/web/program.do?filename.doc HTTP/1.1 
Host: lazy-server 
Connection: keep-alive 
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.24 Safari/536.5 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Accept-Encoding: gzip,deflate,sdch 
Accept-Language: en-US,en;q=0.8,zh-TW;q=0.6,zh;q=0.4 
Accept-Charset: Big5-HKSCS,utf-8;q=0.7,*;q=0.3  

HTTP/1.1 200 OK 
Server: Lotus-DominoDate: Wed, 18 Apr 2012 15:07:45 GMT 
Last-Modified: Wed, 18 Apr 2012 14:50:58 GMT 
Content-Type: application/msword 
Content-Length: 132608 
Accept-Ranges: bytes
The browser known it download the file rather then open it up, as it does not handle the Content-Type: application/msword. However, the server did not include any "Content-Description" header which is usually used to carry the filename for dynamic content.

Then, how the browser guess a name for the file? It take the last part in the URL before the query string. It takes program.do. Some other browser (I mean Firefox here) take the name directly. So, if the "program.do" is "filename.doc", you will get the filename right saved.

However in many web program, they use famous ".cgi" ".do" ."php" ".aspx" extensions in URL. If the browser complete it a simple way, you will save a file you won't able to open without rename it's extension.

The problem is IE and Chrome do one little step more and smarter here.
As it known the Content-Type, as known as MIME type, of the content. It can guess a best file name extension for you by looking you system registry.

And there it found a little known list at "HKEY_CLASSES_ROOT\MIME\Database\Content Type" and ask what is "application/msword". Guess what, registry said it is "Word.Wizard.8" and it usually have extension ".wiz".

There is no one in the world could make that relation other then the programmer who wrote this.

Fix the value, and you will be happy.

沒有留言: