Closed Bug 69306 Opened 24 years ago Closed 23 years ago

[FIX]External apps get spawned with gzip'd files using mod_gzip content-encoding

Categories

(Core Graveyard :: File Handling, defect, P1)

defect

Tracking

(Not tracked)

RESOLVED FIXED
mozilla0.9.9

People

(Reporter: bwatkins, Assigned: bzbarsky)

References

()

Details

(Keywords: testcase)

Attachments

(1 file, 2 obsolete files)

From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; 0.8) Gecko/20010215
BuildID:    2001021508

My web server is set up to serve compressible files as
gzipped files if the user agent claims to accept them.
For example, Micros~1 Word .doc files usually compress 
about 90% and .html files usually compress about 80%.
Pages load faster over any connection, and 3x to 5x faster
over 56k, so this is necessary technology.  The popularity 
of mod_gzip and equivalents is rising rapidly and the
internet experience over 56k is very much improved;  this
is far better than just HTTP1.1 socket keepalive.

Now .html works fine, as do .js and .css.  But when I
download a .doc file from my server, Mozilla launches a
Micros~1 Word window and feeds the file to it.  The only
problem is that Mozilla does not feed Micros~1 Word a
.doc file;  it feeds the raw gzipped file.

So Micros~1 Word comes up with garbage.

This does not happen with Micros~1 Internet Explorer v5.0
because IE5.0 feeds the application the decompressed file.

This does occur in Netscape Navigator 4.7 because NN does
not decompress the file before feeding it to the application.

Note that the gzip'd status of the file is noted in the headers.

This bug is related to bug 51852.

Reproducible: Always
Steps to Reproduce:
1. Go to a mod_gzip enabled web server
2. Download a file that spawns an external viewer, like a
 Micros~1 Word .doc file.

Actual Results:  The file comes up gzip'd

Expected Results:  The file should be decompressed befre being fed to an
external app.

This bug is related to bug 51852.  It is not the same because
this is automatically spawned apps, and that is Save As..., but
the symptom (still compressed files) is the same.
I assume you mean *content* encoding and not *transfer* encoding. Transfer
encoding isn't working at all (bug 59464 and bug 68517). Adjusting summary.
Summary: External apps get spawned with gzip'd files using mod_gzip transfer-encoding → External apps get spawned with gzip'd files using mod_gzip content-encoding
Confirmed
Platform: PC
OS: Windows 98
Mozilla Build: 2001022007

Marking NEW.
Severity: major → normal
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: testcase
Target Milestone: --- → Future
This happens also in the simpler case, where zipping is not applied on-they-fly,
but the content is lying around on the server in this format. Example:

On my webserver, I have some gzipped postscript files, named something.ps.gz.
Apache does the right thing and serves these files with the headers:

Content-Type: application/postscript
Content-Encoding: x-gzip

Mozilla goes and treats the file like application/postscript, a "open or save"
dialog comes up. Saving works fine, as the default filename will end with
".ps.gz" just like in the original. But "open with" will dump the gzipped
content into the tmp area, under randomname.ps. It should be randomname.ps.gz
instead.

(It can be argued that "open with" should save the file in expanded form, but
that's bug 35956's concern)
Works for me with 2001-05-16-04, Win NT. See my comments in bug 35956.
mass move, v2.
qa to me.
QA Contact: tever → benc
The most Apaches has following configuration lines:

AddEncoding     x-compress      Z
AddEncoding     x-gzip          gz tgz

This means that response on request for file named as
somename.tar.gz would have header "Content-Encoding: x-gzip".
Mozilla would save this file gzipped. This is right.
MSIE would save it ungzipped. This is wrong.

But if we have Word document (somedoc.doc) gzipped
on the fly by mod_gzip or mod_deflate then MSIE would
save it ungzipped or run MSWord with ungzipped document.
This is right.

Mozilla would save it gzipped or try to run MSWord with gzipped
document. This is wrong.

I think that Mozilla should save or run any response ungzipped only
if it has .gz or .tgz extention or has content type as
"application/x-tar". In other cases Mozilla should behave as MSIE.
I came to the same conclusion as Igor independently a few weeks back.  Talked to
Darin, who said that seems like an acceptable approach...
Blocks: 120033, 121001
OS: Windows 98 → All
Hardware: PC → All
Attached patch Patch v1.0 (obsolete) — Splinter Review
Proposed patch.  Darin, Bill, would you review?
As a note, that patch fixes the issues in this bug, bug 120033, bug 121001 and
does not regress bug 116445 or bug 35956.
Assignee: neeti → bzbarsky
Component: Networking → File Handling
Keywords: patch, review
Priority: -- → P1
Target Milestone: Future → mozilla0.9.9
Summary: External apps get spawned with gzip'd files using mod_gzip content-encoding → [FIX]External apps get spawned with gzip'd files using mod_gzip content-encoding
>+static char* nonDecodableTypes [] = {

I think this should be:
  static const char * const nonDecodableTypes [] = {

Couldn't this JS code:
>-      const flags = nsIWBP.PERSIST_FLAGS_NO_CONVERSION | 
nsIWBP.PERSIST_FLAGS_REPLACE_EXISTING_FILES;
>+      webBrowserPersist.persistFlags = 
nsIWBP.PERSIST_FLAGS_REPLACE_EXISTING_FILES;
>+      try {
>+        const helperAppService =
>+          Components.classes["@mozilla.org/uriloader/external-helper-app-
service;1"].getService(Components.interfaces.nsIExternalHelperAppService);
>+        if (helperAppService.applyDecodingForType(persistArgs.contentType)) {
>+          webBrowserPersist.persistFlags &= 
~nsIWBP.PERSIST_FLAGS_NO_CONVERSION;
>+        } else {
>+          webBrowserPersist.persistFlags |= 
nsIWBP.PERSIST_FLAGS_NO_CONVERSION;
>+        }
>+      } catch (e) {
>+        webBrowserPersist.persistFlags |= nsIWBP.PERSIST_FLAGS_NO_CONVERSION;
>+      }
>+      

be simplified:
  webBrowserPersist.persistFlags = nsIWBP.PERSIST_FLAGS_NO_CONVERSION |
                                   nsIWBP.PERSIST_FLAGS_REPLACE_EXISTING_FILES;
  try {
    const helperAppService =
            Components.classes["@mozilla.org/uriloader/external-helper-app-
service;1"].getService(Components.interfaces.nsIExternalHelperAppService);
    if (helperAppService.applyDecodingForType(persistArgs.contentType)) {
      webBrowserPersist.persistFlags &= ~nsIWBP.PERSIST_FLAGS_NO_CONVERSION;
    }
  } catch (e) {
  }

I.e., Always or in PERSIST_FLAGS_NO_CONVERSION and then remove that flag iff 
applyDecodingForType returns false?
Attached patch Patch v1.1 (obsolete) — Splinter Review
Make the changes Bill suggests.
Attachment #69961 - Attachment is obsolete: true
mscott should review this...
Attached patch PAtch v1.2Splinter Review
Updated to work with the new world of bug 27609
Attachment #70098 - Attachment is obsolete: true
Comment on attachment 70872 [details] [diff] [review]
PAtch v1.2

r=law
Attachment #70872 - Flags: review+
Comment on attachment 70872 [details] [diff] [review]
PAtch v1.2

sr=darin (looks good!)
Attachment #70872 - Flags: superreview+
Comment on attachment 70872 [details] [diff] [review]
PAtch v1.2

instead of:
PL_strcasecmp(aMimeContentType, nonDecodableTypes[index]) == 0


how about
if (!PL_strcasecmp(...))
Sure thing, if that's the only issue you have with the patch.  :)
checked into trunk for 0.9.9 with mscott's change from "== 0" to "!".
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
*** Bug 107991 has been marked as a duplicate of this bug. ***
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: