Last Comment Bug 57342 - Add "View as Text/HTML/..." option for unknown mime content-type
: Add "View as Text/HTML/..." option for unknown mime content-type
Status: ASSIGNED
parity-opera
: arch
Product: Firefox
Classification: Client Software
Component: File Handling (show other bugs)
: unspecified
: All All
: P1 enhancement with 177 votes (vote)
: ---
Assigned To: Jason Duell [:jduell] (needinfo? me)
:
Mentors:
http://biesi.damowmow.com/mime.php?do...
: 21985 87301 95028 100080 125847 142451 144219 144960 163670 166329 197579 210384 214313 221998 226595 230252 232751 234108 236237 236623 242124 246438 248893 272088 291120 308632 313296 319974 360817 360979 383037 497445 578990 (view as bug list)
Depends on: 69938 217434 227113 52441 176919 217432 217433 369787 504441
Blocks: 11521 78106 78436 185618 191000 258012 266410
  Show dependency treegraph
 
Reported: 2000-10-19 15:43 PDT by pohl
Modified: 2016-06-22 11:12 PDT (History)
173 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
proof-of-concept. DO NOT CHECK THIS IN. (67.82 KB, patch)
2003-08-25 12:25 PDT, Christian :Biesinger (don't email me, ping me on IRC)
no flags Details | Diff | Review
patch v0.1 (31.08 KB, patch)
2003-08-26 04:24 PDT, Christian :Biesinger (don't email me, ping me on IRC)
no flags Details | Diff | Review
Text File with 00 chars (4.32 KB, text/plain)
2004-06-21 08:03 PDT, Brad Clarke
no flags Details
backend patch (34.25 KB, patch)
2004-11-08 09:20 PST, Christian :Biesinger (don't email me, ping me on IRC)
cbiesinger: review-
Details | Diff | Review
ui hack for testing (4.23 KB, patch)
2004-11-08 09:29 PST, Christian :Biesinger (don't email me, ping me on IRC)
no flags Details | Diff | Review
backend patch v2 (32.78 KB, patch)
2004-11-14 09:21 PST, Christian :Biesinger (don't email me, ping me on IRC)
bzbarsky: review-
Details | Diff | Review
backend patch, v3 (37.63 KB, patch)
2005-03-07 16:23 PST, Christian :Biesinger (don't email me, ping me on IRC)
bzbarsky: review+
Details | Diff | Review
backend patch, v4 (35.68 KB, patch)
2005-03-09 13:25 PST, Christian :Biesinger (don't email me, ping me on IRC)
cbiesinger: review+
darin.moz: superreview-
Details | Diff | Review
Toolkit ui hack for testing (3.55 KB, patch)
2007-01-26 04:14 PST, Sylvain Pasche
no flags Details | Diff | Review
backend patch, v4 updated (36.93 KB, patch)
2007-01-26 04:18 PST, Sylvain Pasche
no flags Details | Diff | Review
PoC modal dialog (12.46 KB, patch)
2009-04-27 03:28 PDT, O. Atsushi (Torisugari)
no flags Details | Diff | Review
screenshot of browser file reception dialog that has a grayed out "remember" item (14.33 KB, image/png)
2013-11-26 05:11 PST, Alexander Stohr
no flags Details

Description pohl 2000-10-19 15:43:57 PDT
It appears that there is no way to tell mozilla to display documents of type
text/* (other than text/plain) to display right in the browser window.  I would
like to browse source code files (text/x-java, for example) right in the browser,
but instead I am presented with an open-using/save panel.  Neither of these two
options is the desired choice.  I could not find a way to tell mozilla to treat
text/x-java the same way it treats text/plain.
Comment 1 Asa Dotzler [:asa] 2000-10-24 10:53:25 PDT
over to XPApps
Comment 2 Gervase Markham [:gerv] 2000-11-19 16:15:50 PST
pohl@screaming.org - you couldn't point us at a URL served as text/x-java or 
similar, could you?

Which bits of UI have you looked in to find how to set this, and where would you 
expect such a function to be?

Gerv
Comment 3 pohl 2000-11-20 07:20:02 PST
http://screaming.org/~pohl/ServletWithCache.java


The above link should be a suitable example.  As for where the function should
be, my instincts led me to the
Edit-->Preferences-->Navigator-->HelperApplications where I attempted to add a
mapping for ".java" of type text/x-java.  In the panel where you "add" or "edit"
the mapping, I would imagine that there would be a checkbox (for text/* types)
that says "display within browser window", and perhaps checking this checkbox
would also disable the widgets for selecting the helper application.
Comment 4 pohl 2000-11-20 07:33:15 PST
In addition to a checkbox in the edit/add panel, perhaps there should be a
settable default in the HelperApplications panel itself that says something to
the effect of "by default, documents of type text/* should be (*) displayed
within the browser (*) saved to disk" with radio-buttons to select. them.
Comment 5 sairuh (rarely reading bugmail) 2000-12-06 14:37:29 PST
pardon the spam: reassigning these remaining xp apps bugs of don's to vishy for
the time being. hope that's okay!
Comment 6 Keyser Sose 2000-12-13 14:13:35 PST
Changed summary. Marking as NEW so someone will either mark it as WONTFIX or
INVALID.
Comment 7 pohl 2000-12-13 14:23:58 PST
Keyser Sosez!?  He's comming for me!  Ok, levity aside, is there a reason this
shouldn't be addressed?  WONTFIX and INVALID seem premature.

Changed severity to "enhancement".
Comment 8 Paul Chen 2000-12-29 12:20:35 PST
nav triage team:

Yes, WONTFIX and INVALID seem a bit much. We'll just keep it in the database for 
eons. ;-) Very nice to have, but don't think we'll have time to get to this for 
beta1, marking nsbeta1-
Comment 9 James Salsman 2001-01-02 14:48:28 PST
I believe the logic that controls this kind of thing is presently 
in:  uriloader/exthandler/nsExternalHelperAppService.cpp

I also believe that profile/defaults/mimeTypes.rdf has fields that 
may or may not allow for this already, but I don't know because even 
after asking for several months that database has not yet been 
documented.  Sigh.
Comment 10 Paul Chen 2001-03-20 10:47:26 PST
Marking nsbeta1- bugs as future to get off the radar
Comment 11 James Salsman 2001-05-23 13:00:59 PDT
This is longstading default behavior, to map text/[unknown type]
to text/plain -- this is NOT a feature request!  Please put it 
back on the radar.  Thank you!
Comment 12 James Salsman 2001-05-23 13:04:51 PDT
Another thing:  should this be assigned to bzbarsky@mit.edu (Boris Zbarsky)
since he is working on bug 52441?
Comment 13 James Salsman 2001-05-23 13:11:29 PDT
Boris: please read this one.  Thank you!

Saruh: I am unable to change the "enhancement" and "future" 
fields (that might be a good thing ;-) but not in this case.)  
Would you please?  Also please change the summary to 
"default unrecognized text/* types as text/plain" from
"Allow arbitrary MIME types to be treated as plain text"
Thank you!
Comment 14 timeless 2001-05-23 20:59:57 PDT
jps: This bug doesn't seem to relate to that bug.  So no, unless bz wants this 
bug it shouldn't be forced on him.

Since vishy isn't interested, i'll try an alternative tact: Ask for suggestions 
about a UI.  Once we get a UI spec we can ask someone to implement it.
Comment 15 Boris Zbarsky [:bz] (Out June 25-July 6) 2001-05-24 10:49:20 PDT
There's a comment in bug 52441 about giving the helper app dialog a "show in 
browser" option.  I feel that that would be the best thing to do with this as 
well.  I agree with timeless -- we should decide on a UI for this before 
implementing anything.

I may poke around a bit at the back end to see what's feasible (I don't know 
whether the external handler service can call back into the browser to display 
stuff in the browser window....)

mpt?  Thoughts?
Comment 16 Matthew Paul Thomas 2001-05-26 08:34:41 PDT
Yes -- once we replace the current Unknown Type alert with one that uses 
buttons for commands (avoiding the unfortunate use of radiobuttons as 
commands), those buttons could be:

(Save As ...) (View as Text)     ( Cancel ) ((Open With...))
Comment 17 timeless 2001-05-27 09:59:31 PDT
And what if someone wants to view a document as html or xml? [this is actually 
a real need since many webservers manage to mess up user's mime types]

I suppose (View as ...) would work.  (Treat as ...) might also [but someone 
will say they don't know what treat means, well... you don't view sound so ... 
Handle as ...?]
Comment 18 Matthew Paul Thomas 2001-05-29 23:21:35 PDT
There's a certain point where you have to just give up and make the user do a
bit more work (in this case, save the file with .html extension and open it
locally), rather than trying to handle everything in the alert. Having `Handle
As ...' would be annoyingly incomprehensible for the majority of users who saw
this alert regularly. Already, with `View as Text', we'd be offering them more
power than any other browser I've seen.

--> Networking
Comment 19 Boris Zbarsky [:bz] (Out June 25-July 6) 2001-06-11 10:31:46 PDT
mpt, what's the bug for the new "Unknown Type" dialog?

I've poked a bit and all that needs to happen to "view as text" is the following:

1) reset the mime type to text/plain in the MIMEInfo
2) reset the preferred handler to nsIMIMEInfo::handleInternally

both can be done from Javascript (it's a scriptable interface) so this can be
done in the dialog without too much trouble in my opinion...
Comment 20 Boris Zbarsky [:bz] (Out June 25-July 6) 2001-06-22 09:55:18 PDT
*** Bug 87301 has been marked as a duplicate of this bug. ***
Comment 21 robbe 2001-08-09 04:12:33 PDT
I one-shot solution (via the unknown type dialog) would be fine, but I'm more
interested in a permanent solution, i.e. an option in the preferences to always
show type "foo/bar" raw (as text).

I think mozilla should ship with an entry for text/* that has this option
enabled. Treating any text subtype that is not known as text/plain is actually
MIME standard behaviour. I don't consider that part an enhancement.

Example: http://people.debian.org/~jaqque/debian-issue.sh returns text/x-sh,
which mozilla should display as text.
Comment 22 benc 2001-08-15 11:03:52 PDT
If there is a snippet of MIME specs that shows that, please add it here.
It's futured, so we need a contributor if this is going to happen. 
Comment 23 James Salsman 2001-08-15 19:24:02 PDT
The "MIME specs" suggest that "Text" without a subtype should be 
analyzed to determine if a multibyte set is in use.  I don't know 
whether there is a Unicode-aware version of file(1) aroud to peruse
the logic yet, but that is one place to start looking.  Boris is also 
correct that type specification should be requested when an unknown 
type is encountered.  So, I like this suggestion from tux@centrum.cz 
(Martin Petricek) from duplicate bug 87301, quoted below --


When mozilla encounter unknow content-typ a dialog will appear:
 
[ ] use default action
[ ] use different action
   [ ] save to disk
   [ ] open with application _______
 
-It might be very useful to add something like-
   [ ] view as text/plain
  -- or --
   [ ] treat as [text/plain      ]
 to the dialog (so i can force this to be either text/plain or text/html, etc 
...)
 
 
and maybe add it also to preferences so this could be settable also as default
action
This will help to wiew content-types like netscape/proxy-autoconfig, etc ...
like plain text
Comment 24 robbe 2001-08-22 06:01:15 PDT
I don't know what "specs" James is talking about. I was alluding to RFC2046.
Specifically, section 4.1. of that says:

   Beyond plain text, there are many formats for representing what might
   be known as "rich text".  An interesting characteristic of many such
   representations is that they are to some extent readable even without
   the software that interprets them.  It is useful, then, to
   distinguish them, at the highest level, from such unreadable data as
   images, audio, or text represented in an unreadable form. In the
   absence of appropriate interpretation software, it is reasonable to
   show subtypes of "text" to the user, while it is not reasonable to do
   so with most nontextual data. Such formatted textual data should be
   represented using subtypes of "text".

Later, in 4.1.4:

   Unrecognized subtypes of "text" should be treated as subtype "plain"
   as long as the MIME implementation knows how to handle the charset.
   Unrecognized subtypes which also specify an unrecognized charset
   should be treated as "application/octet-stream".

My take is that, when encountering "text/my-doc-format; charset=us-ascii", to be
compliant, Mozilla must allow display of this as if it were text/plain. It
should (IMHO) treat text/xyz with a missing charset as if charset were UTF-8
(this makes most cases work), and it should allow MIME types other than text/*
to be displayed raw, if that isn't much work.
Comment 25 Tim Powell 2001-09-18 07:19:30 PDT
*** Bug 100080 has been marked as a duplicate of this bug. ***
Comment 26 Matthew Paul Thomas 2001-10-19 08:56:25 PDT
*** Bug 95028 has been marked as a duplicate of this bug. ***
Comment 27 Matthias Versen [:Matti] 2002-02-15 23:30:10 PST
*** Bug 125847 has been marked as a duplicate of this bug. ***
Comment 28 Jeremy M. Dolan 2002-02-15 23:37:40 PST
I can't view any of the text files on:

http://www.samba.org/ftp/unpacked/netfilter/userspace/extensions/

This is quite bad.

Doesn't it make sense to display text/<unknown> as text/plain? The files on that
page are all served as text/x-csrc. I had to save a bunch to disk and use a
console to view them.
Comment 29 Jeremy M. Dolan 2002-02-15 23:39:49 PST
Fixing summary or I'll never be able to find this bug again.
Comment 30 Boris Zbarsky [:bz] (Out June 25-July 6) 2002-02-16 08:18:47 PST
Everyone agrees this would be good.  This at this point requires architecture
changes to the URILoader -- once we determine that we have no content viewer for
the data we seeem to pass it off to the external helper app handler and have no
way of getting it back into core layout again even if the external helper app
handler jumps through hoops.

I'm working on some stuff in there this weekend....  if I fix it, good.  If not,
I would strongly recommend passing on this for 1.0 -- this is the sort of arch
change that should bake on the trunk and in milestones for a while.
Comment 31 Boris Zbarsky [:bz] (Out June 25-July 6) 2002-02-16 11:19:31 PST
OK.  There are actually two separate issues here:

1) Have a way to set user preferences to handle a particular type as plaintext.
   I have the back end of this working in my tree (just reset the type on the
   channel to text/plain and punt the load back to the originating docshell).

2) Have a way for the user to select "view as text" from a helper app dialog
   that comes up for an unknown type. Here the problem is that the data is
   already being sent to dist at this point and the original docshell is no
   longer in the middle of a load -- it thinks it's done.

I have no idea how to solve #2 without completely rearchitecting all the helper
app stuff...

Comment 32 James Salsman 2002-02-16 14:35:38 PST
Good points, Boris.  How about designating one app as the external text viewer, 
and giving it a pick-helper-app button of its own?

The analogous thing, for the faraway ideal of input helper apps, would be to 
have an editor specified as the general INPUT TYPE=FILE ACCEPT=(unrecognized) 
situation.  There, you could have different editors depending on the major type 
name.  

This suggests the question for when the external text "viewer" is offered.  In 
the traditional situation, View Source..., there was a time when the OS text 
selection and copy was disabled on windows.  Not a user-centered feature, and a 
not-very-best laid plan that went astray to the point of absurdity.

To add insult to injury, someone came up with the idea of putting "Open Link in 
Composer" next to "Open Link in new Window."  Many of us with control over 
content-sensitive menus might consider a seperator there.

In short, I want to be able to open anything, even binary files, in any editor 
I specify, but I don't want to do so when I am trying to open it in a new 
navigator window.  I suggest a new menu item, at least ten pixels from "open 
link in new window" with "open in ________" where the blank is filled from a 
preference.  Maybe multiple such global viewers.  And, when I click on 
something purporting to be text/x-quadruple-byte-klingon, I want to chose 
between all my global viewers, and navigator, and something else to be 
specified in further dialog.  And if I choose the latter option, I want to be 
able to add the selected application to be the default for the specific type, 
the default for unrecognized major types -- e.g. text/(unrecognized) -- or a 
new global viewer to add to my context-sensitive menu.
Comment 33 Jesse Ruderman 2002-02-28 16:15:44 PST
*** Bug 21985 has been marked as a duplicate of this bug. ***
Comment 34 Matthias Versen [:Matti] 2002-05-05 18:17:03 PDT
*** Bug 142451 has been marked as a duplicate of this bug. ***
Comment 35 Jesse Ruderman 2002-05-13 16:35:52 PDT
-> file handling
Comment 36 Jesse Ruderman 2002-05-13 16:36:12 PDT
*** Bug 144219 has been marked as a duplicate of this bug. ***
Comment 37 Boris Zbarsky [:bz] (Out June 25-July 6) 2002-05-16 03:26:59 PDT
*** Bug 144960 has been marked as a duplicate of this bug. ***
Comment 38 Matthias Versen [:Matti] 2002-07-09 14:09:11 PDT
*** Bug 156487 has been marked as a duplicate of this bug. ***
Comment 39 Rich Griswold 2002-08-07 14:39:52 PDT
I'd like to see the "View As Text" option for mime types other than text/*.  For
example, right now I can view C source files but not TCL source files.  I
checked, and .c files are sent with a mime-type of text/plain, while .tcl files
are sent with a mime-type of application/x-tcl.  Don't ask me why...  However,
since both are actually plain text, it'd be nice to be able to view both in Mozilla.

Someone suggested forking an external viewer/editor.  This does work (I tried it
for the TCL files), but it isn't as nice as seamlessly viewing in Mozilla along
with other file types.
Comment 40 Jeremy M. Dolan 2002-08-07 15:31:53 PDT
Is there another non-RFE bug for being able to view files such as these? If not,
this should be changed to a non-RFE bug. It's basic functionality that's broken.
Comment 41 pohl 2002-08-07 15:37:17 PDT
That's what I was thinking when I reported the bug.  To me it's just broken.  I
marked it RFE because I didn't want someone to just declare the bug 'invalid'
and lose track of it.
Comment 42 Jesse Ruderman 2002-08-20 10:48:35 PDT
See also bug 108313, Mozilla should display text/foo (where foo is unknown) as
text by default instead of trying to download it.
Comment 43 Jesse Ruderman 2002-08-20 10:57:04 PDT
*** Bug 163670 has been marked as a duplicate of this bug. ***
Comment 44 Jo Hermans 2002-09-03 04:05:56 PDT
*** Bug 108313 has been marked as a duplicate of this bug. ***
Comment 45 Martin Schröder 2002-09-03 06:42:33 PDT
*** Bug 166329 has been marked as a duplicate of this bug. ***
Comment 46 Jonas Jørgensen 2002-09-19 04:12:48 PDT
Related: Bug 11521, View as different media type support.
Comment 47 Max Alekseyev 2002-10-14 20:39:38 PDT

*** This bug has been marked as a duplicate of 11521 ***
Comment 48 Boris Zbarsky [:bz] (Out June 25-July 6) 2002-10-14 20:44:10 PDT
Reopening, since this, unlike bug 11521, may actually be fixable in a reasonable
manner...
Comment 49 Max Alekseyev 2002-10-14 20:53:06 PDT
Hmmm...
Boris, what's about bug 156788 ? Let's reopen it also...
Comment 50 Boris Zbarsky [:bz] (Out June 25-July 6) 2002-10-14 20:57:53 PDT
Nope.  That's precisely an example of the "really hard to solve" case that needs
a full fix to bug 11521.  Note that this bug is talking about types we do _not_
handle internally, for which things are much simpler ("all" we have to do is in
the helper app code reset the type to something we handle and somehow kick the
load back to the browser).  In the case of types we _do_ handle we need to
perform some sort of special reload or something like that... you get a number
of nasty cache-related issues, etc.
Comment 51 Boris Zbarsky [:bz] (Out June 25-July 6) 2003-03-16 16:59:26 PST
*** Bug 197579 has been marked as a duplicate of this bug. ***
Comment 52 Matthias Versen [:Matti] 2003-07-21 15:47:34 PDT
*** Bug 213316 has been marked as a duplicate of this bug. ***
Comment 53 Boris Zbarsky [:bz] (Out June 25-July 6) 2003-07-29 10:10:06 PDT
*** Bug 214313 has been marked as a duplicate of this bug. ***
Comment 54 Bill Mason 2003-08-10 07:39:25 PDT
*** Bug 215706 has been marked as a duplicate of this bug. ***
Comment 55 Ed Avis 2003-08-10 08:12:56 PDT
Someone has quoted RFC2046.  There is also a suggestion in RFC1341 about what to
do with text/strange-unknown-format and similar MIME types:

>In general, the top-level Content-Type is  used  to  declare
>the  general  type  of  data,  while the subtype specifies a
>specific format for that type of data.  Thus, a Content-Type
>of  "image/xyz" is enough to tell a user agent that the data
>is an image, even if the user agent has no knowledge of  the
>specific  image format "xyz".  Such information can be used,
>for example, to decide whether or not to show a user the raw
>data from an unrecognized subtype -- such an action might be
>reasonable for unrecognized subtypes of text,  but  not  for
>unrecognized  subtypes  of image or audio.

I think there is a third 'strand' to this bug that is separate from the two
issues mentioned by Boris Zbarsky.  He mentioned user preferences to handle a
particular type as plain text, and an extra 'view as text' option for a helper
dialogue box.  But for a MIME type that is text/something, shouldn't the browser
just display the document immediately as it does for text/plain?  This should
not require any UI spec - no extra dialogue boxes or prompts are needed, all
that happens is for text/* to be treated the same way as text/plain unless some
more specific handler is set up.

Having a preferences box to treat a particular type as plain text (and not
limited to just text/* MIME types) would be nice; an extra 'view as text' option
in the helper app dialogue box would also be nice.  But neither of these is a
prerequisite for fixing the current default behaviour, so that a text/* document
displays as text rather than being treated as a wholly unknown type.
Comment 56 Boris Zbarsky [:bz] (Out June 25-July 6) 2003-08-10 11:44:42 PDT
So the first time we encounter text/rtf we should just dump it out as plaintext
and not give the user a chance to set up a reasonable handler for that
type?  That's not reasonable.

In fact, that whole section of the RFC is incredibly bogus in my mind,
since most text/* types are in fact not human-readable (this includes
text/html and its ilk; people who code HTML for a living by hand notwithstanding).
Comment 57 Kalin Kozhuharov 2003-08-10 12:59:51 PDT
As Comment #55 states the RFC:

>such an action might be
>reasonable for unrecognized subtypes of text,  but  not  for
>unrecognized  subtypes  of image or audio.

It says _might_ be reasonable, not should. If I try to download a
text/almost-binary-whatever (such as /etc/sendmail.cf), I expect a dialog asking
what to do:

You are trying to view text/almost-binary-whatever content...
() Save to disk...
() Show in browser as text/plain
() Open with program...
 [x] Always do the same for this type  
      [OK] [Cancel]

Just my 2 yen...
Comment 58 Michael Newton 2003-08-10 17:44:25 PDT
My suggestion would be to have a back-end pref with a list of types that are
handled as text/plain. (My pet peeve is trying to view dtd files at w3c.org) 
This would save the extra pref in the ui, but still give advanced users an
option to change it through about:config or the .pref file.  This pref should
come preloaded with things like text/css, text/tab-separated-values,
application/xml-dtd, and others that are known human-readable file types.

Comment 59 Ed Avis 2003-08-11 04:58:52 PDT
I think it's a fair point that defaulting to show-as-plain-text would not give
the user the opportunity to set up a custom handler for text/rtf or whatever. 
On the other hand the current behaviour does not give the user the opportunity
to view a document in the browser.  So you could weigh up which of the two is worse.

But perhaps you don't want to do anything on this until it can be done _right_
(which I assume means an extra UI preference and a 'view in browser' option on
the helper app chooser).  That sounds entirely reasonable.
Comment 60 Christian :Biesinger (don't email me, ping me on IRC) 2003-08-25 12:19:17 PDT
-> me. I have a proof-of-concept.
Comment 61 Christian :Biesinger (don't email me, ping me on IRC) 2003-08-25 12:25:04 PDT
Created attachment 130378 [details] [diff] [review]
proof-of-concept. DO NOT CHECK THIS IN.

this unfortunately includes the "part 2" patch from bug 78919 as well as the
patch for bug 120045 :( sorry about that

I hope the concept is still visible, which is mainly passing an nsIDispatchable
to nsIExternalHelperAppService::DoContent. I'm not very good at coming up with
names, so said name might suck; feel free to suggest a different one.

oh, and you _do_not_ want to run a normal mozilla with this exact patch. you
will be sorry if you do. (that's because it forces all externally handled
content to display as text/plain, for testing purposes)

next step: clean this up a bit, allow this to be called from the helper app
dialog, implement ui for it
Comment 62 Christian :Biesinger (don't email me, ping me on IRC) 2003-08-26 04:24:45 PDT
Created attachment 130410 [details] [diff] [review]
patch v0.1

ok, better version of the patch.

Comments on this patch are welcome.

Note: UI is not final yet.
I'm thinking of something like this:

  (o) View as [Text    v]
with the dropdown containing:
  +---------------+
  | Text	  |
  | Image	  |
  | HTML	  |
  | XML (maybe)   |
  | Other...	  |
  +---------------+

Where "Other..." allows the user to manually enter a mime type.

oh, btw... this patch removes pre-downloading while the dialog is up. it
doesn't do cleanup that would be allowed by this change, though. guess I'll do
that in another patch.
Comment 63 Boris Zbarsky [:bz] (Out June 25-July 6) 2003-08-26 10:47:37 PDT
> oh, btw... this patch removes pre-downloading while the dialog is up. 

Please make that a separate patch, and do it first if needed for this bug.  
That change needs to be done somewhat carefully in the face of how stream 
converters work, and it will be simpler to debug the more localized changes.
Comment 64 Alex Bishop 2003-08-26 15:11:28 PDT
> Note: UI is not final yet.
> I'm thinking of something like this:
>
>   (o) View as [Text    v]
> with the dropdown containing:
>   +---------------+
>   | Text	    |
>   | Image	    |
>   | HTML	    |

'Web Page' would probably be more understandable for most users.

>   | XML (maybe)   |

Or maybe not. :-)
Comment 65 Bill Mason 2003-10-13 06:39:03 PDT
*** Bug 221998 has been marked as a duplicate of this bug. ***
Comment 66 Christian :Biesinger (don't email me, ping me on IRC) 2003-10-23 14:45:18 PDT
note to self, mReceivedDispositionInfo seems to be sufficient for
mSuspended=TRUE, so the latter variable can maybe be eliminated
Comment 67 Boris Zbarsky [:bz] (Out June 25-July 6) 2003-11-23 14:55:19 PST
*** Bug 226595 has been marked as a duplicate of this bug. ***
Comment 68 Mats Palmgren (:mats) 2004-01-06 16:13:15 PST
*** Bug 230252 has been marked as a duplicate of this bug. ***
Comment 69 Boris Zbarsky [:bz] (Out June 25-July 6) 2004-02-01 10:39:42 PST
*** Bug 232751 has been marked as a duplicate of this bug. ***
Comment 70 Boris Zbarsky [:bz] (Out June 25-July 6) 2004-02-12 18:13:00 PST
*** Bug 234108 has been marked as a duplicate of this bug. ***
Comment 71 Felix Miata 2004-03-02 20:11:22 PST
*** Bug 236237 has been marked as a duplicate of this bug. ***
Comment 72 Boris Zbarsky [:bz] (Out June 25-July 6) 2004-03-06 00:05:21 PST
*** Bug 236623 has been marked as a duplicate of this bug. ***
Comment 73 Vaclav Dvorak 2004-04-10 08:25:32 PDT
Were there any big problems with the patch? Biesi, will you be working on it?
Thanks.
Comment 74 Christian :Biesinger (don't email me, ping me on IRC) 2004-04-10 08:49:17 PDT
(In reply to comment #73)
> Were there any big problems with the patch? Biesi, will you be working on it?
> Thanks.

yes, it breaks saving IMAP attachments, as well as saving files from some http
servers.

I need to find a solution for that... targeting optimistically
Comment 75 David Nesting 2004-04-21 09:35:17 PDT
I might encourage this bug to also include the case of application/<unknown>+xml
(or <anything>+xml?).  Sometimes I'm hitting an XML MIME type that the browser
doesn't explicitly handle, and receive the same type of dialog as the
text/<unknown> case.  In this situation, though, it's an XML document (as
evinced by the +xml suffix), and Mozilla can display XML, at least in tree form.
 See also bug 194351.
Comment 76 Asa Dotzler [:asa] 2004-04-27 18:38:22 PDT
*** Bug 210384 has been marked as a duplicate of this bug. ***
Comment 77 Christian :Biesinger (don't email me, ping me on IRC) 2004-04-29 15:05:57 PDT
*** Bug 242124 has been marked as a duplicate of this bug. ***
Comment 78 Chapman Flack 2004-05-21 15:19:48 PDT
comment 18 suggests that adding this enhancement would offer users "more power
than any other browser I've seen" - as if that's a reason not to do it.  The
suggested alternative is "make the user do a bit more work" - so the user is
protected from something "annoyingly incomprehensible" like a Handle As...
option, and instead only has to download the silly file, open a shell window and
rename the file to have a recognized extension, and go back to Moz and type in a
file: url for the new file in order to view it.  And remember to remove the file
after.

That isn't any more comprehensible or less annoying to a novice user, and if I
had a novice user on a support line I'd much rather be able to say "hmm, dialog
asking what to do with application/x-pdf? Yeah, just pick Handle as
application/pdf, it'll be fine."

I actually see things served as application/x-pdf often enough that I have an
entry in MIME types for "Mislabeled Portable Document Format". :(  And then
there's always the occasional html/text or txt/html or other wacky content type
where you see it and you know immediately what it was supposed to be but you
have to go run around the block in order to view it.

For UI, I'd suggest that Handle As... gives you a selection box to pick from any
of the types currently known to the browser, ideally with more common ones and
closest fuzzy matches to the served content type toward the top.  With a tip for
the Handle As button saying something like "Use if you think you know what type
this document really is" I don't think it really has to be incomprehensible.
Comment 79 Christian :Biesinger (don't email me, ping me on IRC) 2004-05-21 15:52:58 PDT
comment 62 suggests UI already. I'm quite hesitant to add more items to the
list... Maybe there should be an additional one for a type guessed from the file
extension, but that should be all, I think.
Comment 80 John Sullivan 2004-05-21 17:41:13 PDT
I disagree.

This is a common enough problem, and being one where the people causing the
problem, or at least capable of solving it, are generally not the ones suffering
from it, and may not be open to fixing it since the people capable of actually
explaining what the problem is are a very small subset of their audience, or
they may not be directly contactable through the corporate bureaucracy, this
merits very careful thought about how the problem can be mitigated from the
client side.

There are cases where a resource can be opened, will force the "Save As" dialog,
and if saved and double-clicked will immediately open the browser which will
render it fine. This is quite clearly a ridiculous situation! We know why it
happens but the user experience is just stupid.

Certainly there are a few common media types which, for a user who can see what
the resource ought to be handled as, they should be able to easily override the
Save As prompt and cause the resource to be opened by that built-in handler. I'm
thinking here "Plain Text", "HTML", "JPEG image", "GIF image". Plus a few more.
PNG, XML etc. The list isn't huge, will cut out 99.9% of erroneous mimetype
problems, and if a confused user chooses the wrong thing they can always try
again and are in no worse situation than they started off.

Possibly this should be defaulted based on the resource "filename extension" - I
can't see that being a problem (in many cases it just won't work, but is no
worse than not doing so). Defaulting based on the first few bytes of the
resource would be better. Possibly, if we really want to keep that dialog
absolutely as simple as possible then it should be made an expandable dialog
with an "Advanced/More>>>" button - I don't see a problem with that either.

But there *does* need to be an escape route, because the failure mode results in
far more effort than is reasonable to work around, currently. It *should* just
work transparently, yes, but it sometimes doesn't and in those cases it really
doesn't need to fail that badly.

Choosing obvious stuff from a list is an absolute minimum. The real expert user
will also want to be able to type in a literal mimetype. Hide these by default
if you're really worried about scaring some users, but they ought to exist somehow.

(I'd also like to point out that "unknown mimetype" is not the only problem -
there are cases where the mimetype is recognised but mislabelled. In these cases
it would be useful to be able to invoke something similar to the Save As dialog
manually on a link. The example that springs to mind is download sites that
mislabel PKZIP or Windows executable files as text/plain. In fact I'd really
like to see a check for resources starting in PK or MZ and throwing a dialog
saying "Are you sure you want to open this as text or HTML", but that's getting
beyong the scope of this bug.)
Comment 81 Christian :Biesinger (don't email me, ping me on IRC) 2004-05-22 04:55:17 PDT
> will also want to be able to type in a literal mimetype

see the "other" part of comment 62

> like to see a check for resources starting in PK or MZ 

current mozilla versions check if the first 1000 bytes or so of the data
contains binary content and show the helepr app dialog if so (assuming the type
is text/plain). that is indeed a different bug.
Comment 82 Chapman Flack 2004-05-24 15:25:05 PDT
Should the summary be changed from

  Add "View as Text" option for unknown mime content-type

to something like

  "View as [Text|...]" option for unknown/wrong mime content-type

since the discussion seems to be converging that way and not to have Text as the
single, fixed option?
Comment 83 Kalin Kozhuharov 2004-05-24 17:39:22 PDT
After almost 4 years discussing, shouldn't this bug be fixed somehow?
:-(
Comment 84 Christian :Biesinger (don't email me, ping me on IRC) 2004-05-24 17:52:17 PDT
yes.
Comment 85 David Nesting 2004-05-29 08:24:34 PDT
(In reply to comment #80)
> Possibly this should be defaulted based on the resource "filename extension"

It's important to note that the whole concept of a "file extension" is OS-
dependent and only meaningful on operating systems that determine a file's 
type from it's file extension.  In the HTTP world and on most non-Windows 
OS's, a file's extension has no meaning and is opaque.

This is part of why server misconfigurations are so annoying: the server-
provided MIME type *should* be the final authority on what the content is.  I 
strongly advise against following IE's behavior here and second-guessing 
things that look too generic.  The problem is with the site, and in this case, 
the site author *is* using IE exclusively to test things (or isn't testing at 
all), which is why we're in this mess to begin with.

We certainly need a way to override MIME types that are incorrect, but we 
should look towards correcting the problem (the server misconfiguration) 
first, and treat this as a temporary workaround until a real fix is 
performed.  For that reason, none of this should be performed automatically or 
without notifying the user.  We should NEVER do the IE thing here and 
*silently* use our own second-guessed MIME type in place of what *appears* to 
be a generic or misconfigured MIME type.

I do like the idea of an "Advanced/More >" thing, and we should be able to 
pull this dialog up even when Mozilla has a good idea of what to do with the 
resource as it's currently labeled.
Comment 86 James Salsman 2004-05-29 12:36:28 PDT
While I agree with David's comment 85, I note that on unix systems which don't
depend on the file extension, content type-guessing programs such as file(1) are
certainly allowed to use the filename in making a decision about what to report.
 On the other hand, those guessing programs ought to be able to get /dev/stdin
correct most of the time.  The filename should only be used to resolve
ambiguities when it is available, and there is nothing wrong with asking the
user to confirm such ambiguity resolution, except (and this case is probably
rare) when it becomes an encumberance to the user being able to proceed at their
customary pace.

If you wanted to accommodate that, Christian, you might include a "Don't ask me
to confirm such guesses again" checkbox, but I wonder how useful overall that
would be.
Comment 87 Christian :Biesinger (don't email me, ping me on IRC) 2004-06-12 05:29:56 PDT
*** Bug 246438 has been marked as a duplicate of this bug. ***
Comment 88 Brad Clarke 2004-06-18 11:56:59 PDT
Other changes in 1.7 have broken web sites that I used in 1.6 without issues.
The changes reference this as the "fix" for their breaking stuff, so I'd
encourage those involved to fix this as soon as possible.
Comment 89 M. Creidieki Crouch 2004-06-19 13:52:45 PDT
I believe this is a duplicate of bug 121498.
Comment 90 Mike Cowperthwaite 2004-06-20 09:24:14 PDT
(In reply to comment #89)
> I believe this is a duplicate of bug 121498.

No; this proposes a more extensive solution.  Solving this would solve that bug, 
but the reverse is not necessarily true.


(In reply to comment #88)
> Other changes in 1.7 have broken web sites that I used in 1.6 without issues.
> The changes reference this as the "fix" for their breaking stuff, so I'd
> encourage those involved to fix this as soon as possible.

Brad Clarke, could you cite those changes/bugs, please?
Comment 91 Brad Clarke 2004-06-21 07:51:38 PDT
After some offline discussion it was determined that the problem is with txt 
files with 00 in them (I'll attach one for you).
Comment 92 Brad Clarke 2004-06-21 08:03:52 PDT
Created attachment 151357 [details]
Text File with 00 chars
Comment 93 Kalin Kozhuharov 2004-06-21 08:16:32 PDT
(In reply to comment #88, comment #91, comment #92)
Brad,
please try to use a few more words to explain what you are trying to say.

What about the file attached?
If you look at it from bugzilla, it will (and is) served as text/plain, so
everything should work (works in 1.6 at the moment).

What broke in 1.7. for you?
Comment 94 Brad Clarke 2004-06-21 08:37:42 PDT
The file here on bugzilla even seems to open fine :/

In 1.6 it opens just fine in the browser. In 1.7 I get the download dialog with 
the content type showing as "text/plain" and the default application 
being "txtfile" (notepad). Since notepad displays the txt file fine with no 
formatting problems or unprintable characters, the content type from the server 
is "text/plain" and the extension for the file is "txt" it's very odd to me 
that 1.7 can't just display it.

Other txt files in the same directory on the web server open in 1.7 just fine. 
It's being served by a very simple servlet from tomcat which you can see here:
http://cvs.sourceforge.net/viewcvs.py/cruisecontrol/cruisecontrol/reporting/jsp/
src/net/sourceforge/cruisecontrol/servlet/FileServlet.java

Please let me know if there is any more information I can provide.
Comment 95 Christian :Biesinger (don't email me, ping me on IRC) 2004-06-21 10:30:31 PDT
please, keep that discussion out of this RFE. it is working as designed, and
pretty unrelated to this bug. bugzilla attachments do not exhibit this
behaviour, because their content-type header is neither "text/plain" nor
"text/plain; charset=iso-8859-1". please discuss further issues with this in a
newsgroup, private mail, or different bug. thank you.
Comment 96 Ted Mielczarek [:ted.mielczarek] 2004-07-08 06:24:04 PDT
*** Bug 248893 has been marked as a duplicate of this bug. ***
Comment 97 era+mozilla 2004-07-13 00:19:38 PDT
I have found that http://www.spamhaus.org/ will frequently bring up the "Save As
..." dialog.

It appears that it doesn't send a Content-Type: at all, and that apparently,
this is interpreted as application/octet-stream

I can't always repro this; don't know if they have multiple servers or if
they're changing their configuration back and forth between something which
works with Mozilla and something which doesn't.

In any event, I would very much like to be able to specify that it's just HTML
and it should be opened in the browser and not Saved As ... anything.
Comment 98 Michal Svec 2004-07-19 09:32:04 PDT
Can't finally someone take a look at this? I can't understand why such
simple thing can't be done for 4 (!) years ...
Comment 99 James Ross 2004-07-19 09:49:32 PDT
(In reply to comment #98)
> Can't finally someone take a look at this? I can't understand why such
> simple thing can't be done for 4 (!) years ...

Then maybe you should try fixing it yourself? See points 1.1 and 1.2 here:
http://bugzilla.mozilla.org/page.cgi?id=etiquette.html
Comment 100 Michal Svec 2004-07-20 02:23:08 PDT
Sorry, I didn't mean any offense. I still hope this annoying bug is finally
going to be fixed one day.
Comment 101 Christian :Biesinger (don't email me, ping me on IRC) 2004-07-20 04:47:57 PDT
it is going to be fixed one day, unfortunately bug 227113 is a real problem that
stands in the way of fixing it, and it's somewhat hard to fix. bug 217434 too,
but less of a problem... that's why those bugs are marked as blocking this one.
so this bug now has 4 more useless comments, that nobody will read. thank you
very much.
Comment 102 Michal Svec 2004-07-21 03:59:44 PDT
I can't follow the other bugs (I simply do not understand them), however
what I really wonder is why we need this huge discussion in the first place.

Excuse my dumb mind, but why can't it be done some way like this:

  .configfile:
    # treat-these-mimes-as-plain-text
    ttmapt: text/x-sh, text/x-java <empty by default>

  browser mime handler:

    [... handling file with $mime ...]    
    if(contains($ttmapt, $mime)) $mime = text/plain;
    [ ... go on with $mime handling ...]
Comment 103 era+mozilla 2004-07-21 04:25:54 PDT
Prompted by the previous comment, I looked into the "depends on" links to bugs
which are not yet fixed.

Not a single one of them makes much sense to me.

Maybe I'm dense, but even if so, it would be useful to document exactly why this
bug depends on bug 69938 (downloaded files are needlessly downloaded to a
temporary location), bug 217434 (IMAP suspend/resume issue [sic]), and bug
227113 (stream converter suspend/resume issue ... what's a stream converter
anyway?), or else remove those dependencies.

In fact, while I doubt it will do much good, I'm taking the liberty to (attempt
to) remove them here and now.
Comment 104 Christian :Biesinger (don't email me, ping me on IRC) 2004-07-21 04:44:06 PDT
arg, can you stop touching the dependencies of my bugs? summary of the issue is:
we want to offer the "view as ..." option in the helper app dialog (as the
summary of this bug says). this means we want to stop the networking code from
continuing sending us data while the dialog is up, so that we can send it to the
appropriate other component in the mozilla code instead. This means Suspend(),
the function that means "do not send data until Resume() is called", needs to
work reliably. hence the dependencies.

> Excuse my dumb mind, but why can't it be done some way like this:

well, technically that'd be doable. practically, no user would be able to
discover it...
Comment 105 Hixie (not reading bugmail) 2004-07-21 04:51:52 PDT
Woah, woah. This shouldn't require us to break the download streaming. It 
doesn't break it in Opera, why would it break it in Mozilla?
Comment 106 Arthur 2004-07-21 10:51:09 PDT
(In reply to comment #62)
> patch v0.1

  So about a year ago there was a preliminary patch for this bug that seems
to do everything /I/ want it to do.  I'm a newbie here; can someone please
point me to (preferably) a binary containing that patch, or else instructions
on how to get sources for and build the patched browser?  I know several
other people who would like this, too.
Comment 107 Christian :Biesinger (don't email me, ping me on IRC) 2004-07-21 12:37:28 PDT
(In reply to comment #105)  
> Woah, woah. This shouldn't require us to break the download streaming. It   
> doesn't break it in Opera, why would it break it in Mozilla?  
  
intersting. how does opera do it, especially in case of gzipped content? does  
it read half of the data from the file again?  
  
(In reply to comment #106) 
> on how to get sources for and build the patched browser?  I know several 
> other people who would like this, too. 
 
http://www.mozilla.org/build/ 
 
Comment 108 Chapman Flack 2004-07-22 16:20:28 PDT
Another example of a very common server type-mislabeling trick that
inconveniences the user happens with Mailman-maintained mailing list archives. 
These archives always have a monthly (or some other period) archive file that is
gzip'd text.  It usually comes labeled as:

  Content-Type: application/x-gzip

instead of the correct:

  Content-Type: text/plain
  Content-Encoding: gzip

and as simple as the problem is, there is no way I've ever found to get Mozilla
to show the text instead of insisting on saving to file.

This example is Mailman bug 905910:
https://sourceforge.net/tracker/?func=detail&atid=100103&aid=905910&group_id=103

... but even if it gets fixed in Mailman, lots of Mailman sites out there will
surely be sending mislabeled files for a long time after, so the browser needs
some way for the user to cope.
Comment 109 Hixie (not reading bugmail) 2004-08-10 02:41:32 PDT
>> Woah, woah. This shouldn't require us to break the download streaming. It   
>> doesn't break it in Opera, why would it break it in Mozilla?  
>   
> intersting. how does opera do it, especially in case of gzipped content? does  
> it read half of the data from the file again?  

Do you have a test case that I can check? I'm not familiar with this corner of 
HTTP enough to reliably create it myself. (Alternatively, explain exactly what I 
should test using HTTP headers and content and I'll try to do it myself.)

I'm not sure exactly how Opera does it, but many possibilities come to mind, 
such as streaming the data into memory instead of disk, streaming the data into 
the cache unchanged until a final location is picked (and then decoding it on 
copy instead of just moving it, if that is necessary), or saving the file data 
gzipped and then uncompressing it if required.
Comment 110 Ginn Chen 2004-08-10 03:13:27 PDT
Just find a link of .tar.gz file, left click the link.
Mozilla will ask you save it to disk or open it.
1)If select save, you will find the file you saved was gunzipped but still named
as .tar.gz.
2)If select open, you will find it fail to be opened, and find something in your
/tmp.

Really annoy.

Comment 111 Christian :Biesinger (don't email me, ping me on IRC) 2004-08-10 08:05:48 PDT
(In reply to comment #109)
> Do you have a test case that I can check? I'm not familiar with this corner of 
> HTTP enough to reliably create it myself. (Alternatively, explain exactly what I 
> should test using HTTP headers and content and I'll try to do it myself.)

OK... hm... try this:
- name the file foo.html.gz
- send as:
Content-Type: text/html
Content-Encoding: gzip
Content-Disposition: attachment
- content should be gzipped, of course.

Expected behaviour: When I "View as HTML" or "View in Browser" or something, I
want to see the ungzipped HTML, of course. When saving, I want the .html.gz file
contain gzipped content.
When I click "Open using [iexplore.exe    ] [Choose...]" I expect the content to
be decoded before passed to msie.

.tar.gz is probably not such a good example; you won't want a "view in browser"
there. but maybe testing w/ helper apps is a good idea too:
name foo.tar.gz
content-encoding: gzip
content-type: application/x-tar

Saving to a file should absolutely not decode. Opening in an application
probably should decode, with appending .tar...


foo.doc
content-encoding:gzip
content-type:application/msword

that should always decode.
Comment 112 Chapman Flack 2004-08-10 09:40:19 PDT
Gleep!  I'm not sure I like the sound of having a dozen ad-hoc rules for when to
decode or not and what to do with file extensions--especially because as far as
http is concerned, the Content-Type and Content-Encoding headers are everything
and filename extensions are invisible to the standard.

I would suggest two very simple rules to apply in perfect uniformity, regardless
of the type of data.

1.  If it's to be processed/displayed internally, then of course undo the encoding.

2.  If it's to be saved to a file, and has a non-null Content-Encoding that
Mozilla knows how to undo, give the user radiobuttons on the save dialog:

  This file was sent with the encoding: gzip
  O  save in this encoding
  O  undo encoding and save

Then you can add file extension *heuristics* if you want, say for example if the
encoding is gzip and the suggested name in the Save dialog ends in .gz then
change the suggested name to without the .gz ... that makes these convenience
suggestions that the user sees in the dialog and has the choice to accept, not a
plethora of rules that get applied for various content types and make the user
try to figure out what happened.

As for what to do when invoking a helper: the real answer is probably allow each
helper definition to include an Accept-Encoding list.  If a file comes in an
encoding the helper accepts, Moz passes the file unchanged.  If the helper does
not accept the encoding but Moz knows how to decode it, then Moz decodes. 
Otherwise, need to ask the user what to do.

An alternative to accept-encoding list per helper is for helpers to be a
relation indexed by (content-type, encoding).  That way you could support a
helper that can accept a certain encoding but needs maybe different command line
options to do it, because the entry for that (type,encoding) pair would be able
to have its own command line.  But I'm not sure all of these considerations need
to be handled for THIS bug....
Comment 113 Christian :Biesinger (don't email me, ping me on IRC) 2004-11-04 15:16:00 PST
solution: never offer this option when we decided not to apply encodings. that
allows us to easily do this.
Comment 114 Christian :Biesinger (don't email me, ping me on IRC) 2004-11-08 09:20:42 PST
Created attachment 165149 [details] [diff] [review]
backend patch
Comment 115 Christian :Biesinger (don't email me, ping me on IRC) 2004-11-08 09:24:10 PST
Comment on attachment 165149 [details] [diff] [review]
backend patch

this does not provide a good solution for the frontend to figure out whether a
certain mime type is supported... do you think I should add such a method to
nsIDispatchable? Or should the frontend figure that out for itself (eg by
querying the Gecko-Content-Viewers category)? I'm not sure currently what I
prefer...
Comment 116 Christian :Biesinger (don't email me, ping me on IRC) 2004-11-08 09:29:12 PST
Created attachment 165152 [details] [diff] [review]
ui hack for testing

this is a patch to the UI that I used for testing; it is totally unsuitable for
checkin, but it shows how the backend can be used.
Comment 117 Boris Zbarsky [:bz] (Out June 25-July 6) 2004-11-09 12:18:41 PST
I'll try to get to this in the next few days...
Comment 118 Christian :Biesinger (don't email me, ping me on IRC) 2004-11-14 09:20:43 PST
Comment on attachment 165149 [details] [diff] [review]
backend patch

forgot to change the uuid...
Comment 119 Christian :Biesinger (don't email me, ping me on IRC) 2004-11-14 09:21:40 PST
Created attachment 165908 [details] [diff] [review]
backend patch v2
Comment 120 Matthias Versen [:Matti] 2004-11-28 04:38:31 PST
*** Bug 272088 has been marked as a duplicate of this bug. ***
Comment 121 Boris Zbarsky [:bz] (Out June 25-July 6) 2004-12-04 23:00:36 PST
Comment on attachment 165908 [details] [diff] [review]
backend patch v2

>Index: uriloader/base/nsURILoader.cpp
>+NS_IMETHODIMP nsDocumentOpenInfo::ReDispatch(const nsACString& aMIMEType,

This wants to NS_PRECONDITION aData and NS_PRECONDITION aRequest, right?

Also, why is it ok to have an aRequest here that's not a channel?  When would
that happen, exactly?  URILoader in general only handles channels, and we
really do want a channel here to be able to do SetContentType...

>+  // Save type and stream listener

"save old type and stream listener in case we fail to redispatch", right?

>+    rv = aData->Available(&count);
>+    // XXX what if that failed?

We cancel aRequest with rv?  That would make the most sense...

>+    rv = m_targetStreamListener->OnDataAvailable(aRequest, nsnull, aData, 0, count);

Hmm... I guess this is an OK context to pass, since there's really no better
one in sight, and we _did_ open this channel ourselves with a null context,
huh?

Could you write a comment to that effect?

>   nsCOMPtr<nsIExternalHelperAppService> helperAppService =
>     do_GetService(NS_EXTERNALHELPERAPPSERVICE_CONTRACTID, &rv);
>-  if (helperAppService) {
>+  if (!aAllowExt) {
>+    rv = NS_ERROR_NOT_AVAILABLE;
>+  } else if (helperAppService) {

I think this would be clearer written as:

nsCOMPtr<nsIExternalHelperAppService> helperAppService;
if (allowExt) {
  helperAppService =
    do_GetService(NS_EXTERNALHELPERAPPSERVICE_CONTRACTID, &rv);
} else {
  rv = NS_ERROR_NOT_AVAILABLE;
}
if (helperAppService) {
...


> nsDocumentOpenInfo::TryContentListener(nsIURIContentListener* aListener,
>-                                       nsIChannel* aChannel)
>+                                       nsIRequest* aRequest)

I'm not so enamored of that change, for the same reasons as apply to the first
comment on this patch...

>-  NS_PRECONDITION(aChannel, "Must have a channel");
>+  NS_PRECONDITION(aRequest, "Must have a channel");

If the change _is_ made, please fix the assert text.

>Index: uriloader/exthandler/nsExternalHelperAppService.cpp

>+NS_IMETHODIMP nsExternalAppHandler::GetCanHandleAs(PRBool* aCanHandleAs)

This would be better named GetCanCallHandleAs, I think...

> NS_IMETHODIMP nsExternalAppHandler::OnStopRequest(nsIRequest *request, nsISupports *aCtxt, 

>-  mRequest = nsnull;

You sure this doesn't introduce any cycles?  Maybe we want to null it out here
only if we've got disposition info or something?

>@@ -2115,12 +2126,15 @@ nsresult nsExternalAppHandler::CreatePro
>   mDialog = nsnull;
>+
>+  mDispatchable = nsnull;
>+

Add a comment explaining that this breaks the cycle?

>+NS_IMETHODIMP nsExternalAppHandler::HandleAs(const nsACString& aMIMEType)

This needs to enforce the constraints of GetCanHandleAs() and throw if that
would return false, I think....

>Index: uriloader/exthandler/nsIExternalHelperAppService.idl

>+interface nsIDispatchable : nsISupports

Could we please put this in a different file?  Especially if we expect to allow
embeddors to implement nsIDispatchable?

Then again, do we expect people to either call nsIExternalHelperAppService
directly or to implement it?  If not, perhaps none of these need be public
apis?  I suppose that's for another bug, huh?  :)

>+   * In no case will this re-enter the original content handler.

This can only be guaranteed if the original content handler is the helper app
service, no?  I think this should be clarified.

>+   * *When this function returns successfully, the current handler WILL NOT
>+   *  get an onStopRequest call!*

Maybe it should?  Would that actually break anything in this case?

>+   * THIS MUST NOT BE CALLED FROM doContent!

This is an internal implementation notes for nsExternalHelperAppService, no?  I
don't see how it would apply in general...  Again, do we expect embeddors to
implement nsIExternalHelperAppService?

>+   * This method may be called event after onStopRequest has been called,

"even", not "event".  Which onStopRequest?  That's non-obvious from looking at
this interface.

>+   * in which case the new listener will receive an onStopRequest call before
>+   * this method returns.

Will or must?  That is, is this documentation for implementors of
nsIDispatchable, or for coders in nsExternalHelperAppService?  The latter
reaslly does not belong here...

>+   * @param aRequest
>+   *        The request to dispatch as. Must be the same as passed to doContent.
>+   *        XXX this sucks.

I rather agree....  I'm not sure what the best way to fix this is,
conceptually.  Perhaps some verbiage indicating the overall interaction of
nsIExternalHelperAppService and nsIDispatchable is in order?

>+   *        No content handler for the registered type was registered; or the
>+   *        current handler is the handler for the requested type.

Do we ever enforce the latter condition?  I don't believe we do, and don't see
a good way to do it without assuming that the current handler is always the
externalhelperappservice.

>+  void handleAs(in ACString aMIMEType);

This should document that it throws anytime canHandleAs is false or something
like that.  At the very least, canHandleAs needs to be mentioned here.
Comment 122 Christian :Biesinger (don't email me, ping me on IRC) 2004-12-14 16:07:47 PST
(In reply to comment #121)
> This wants to NS_PRECONDITION aData and NS_PRECONDITION aRequest, right?

fine with me to make aRequest a precondition. aData is allowed to be null though
(see the interface docs).

> Also, why is it ok to have an aRequest here that's not a channel?  When would
> that happen, exactly?  URILoader in general only handles channels, and we
> really do want a channel here to be able to do SetContentType...

hm... yeah, that makes sense I guess.

> >+  // Save type and stream listener
> 
> "save old type and stream listener in case we fail to redispatch", right?

indeed. will make that change.

> >+    rv = aData->Available(&count);
> >+    // XXX what if that failed?
> 
> We cancel aRequest with rv?  That would make the most sense...

ok. I guess Cancel will always succeed ;) (it better...)

> Hmm... I guess this is an OK context to pass, since there's really no better
> one in sight, and we _did_ open this channel ourselves with a null context,
> huh?

we always pass a null context currently...

> Could you write a comment to that effect?

sure

> I think this would be clearer written as:

ok

> I'm not so enamored of that change, for the same reasons as apply to the first
> comment on this patch...

I think I had a good reason for that change. wish I remembered it...

> >+NS_IMETHODIMP nsExternalAppHandler::GetCanHandleAs(PRBool* aCanHandleAs)
> 
> This would be better named GetCanCallHandleAs, I think...

hmm... ok... I'd prefer my name, but sure.

> You sure this doesn't introduce any cycles?  Maybe we want to null it out here
> only if we've got disposition info or something?

Ah... I can do that. my thinking was that the only reference was through necko
-> streamlistener (documentopeninfo) -> exthandler.

> Add a comment explaining that this breaks the cycle?

ok...

> This needs to enforce the constraints of GetCanHandleAs() and throw if that
> would return false, I think....

oh yeah, good point.

> Could we please put this in a different file?  Especially if we expect to allow
> embeddors to implement nsIDispatchable?

I dunno, do we? ;) sure, fine with me. in uriloader/base or exthandler? I guess
base is better (I envision possibly passing this to nsIURIContentListener
objects as well, sometime in the future)

> Then again, do we expect people to either call nsIExternalHelperAppService
> directly or to implement it?  If not, perhaps none of these need be public
> apis?  I suppose that's for another bug, huh?  :)

implement it? heh. that's a really good question. personally, I don't expect
anybody to implement it ;)

> >+   * In no case will this re-enter the original content handler.
> 
> This can only be guaranteed if the original content handler is the helper app
> service, no?  I think this should be clarified.

that's the only object currently which gets an nsIDispatchable? the code would
have to be expanded if we ever pass it to other handlers, sure. I am not sure
that I want to give up this precondition, it seems important to let the current
handler rely on this.

> >+   * *When this function returns successfully, the current handler WILL NOT
> >+   *  get an onStopRequest call!*
> 
> Maybe it should?  Would that actually break anything in this case?

I'd have to check. it probably should get onStopRequest... maybe with a special
status code? (NS_BINDING_RETARGETED?) I suspect onstopr currently doesn't deal
with that very well.

> >+   * THIS MUST NOT BE CALLED FROM doContent!
> 
> This is an internal implementation notes for nsExternalHelperAppService, no?  I
> don't see how it would apply in general...  Again, do we expect embeddors to
> implement nsIExternalHelperAppService?

I don't see how that follows... if doContent does call it, we re-enter uriloader
while it's not done with DoContent yet. that seems scary. it would also mean
that the new target listener gets two onstartrequest calls (one from uriloader's
onstartrequest, to which dispatchcontent returns, to which docontent returns;
one from ReDispatch). so this does seem like an nsIDispatchable issue. I can
rephrase it as "Must be called in or after onStartRequest", if you prefer that.

> >+   * This method may be called event after onStopRequest has been called,
> 
> "even", not "event".  Which onStopRequest?  That's non-obvious from looking at
> this interface.

well, the current handler's... I'll mention that.

> >+   * in which case the new listener will receive an onStopRequest call before
> >+   * this method returns.
> 
> Will or must?  That is, is this documentation for implementors of
> nsIDispatchable, or for coders in nsExternalHelperAppService?  The latter
> reaslly does not belong here...

well, both. interface documentation can be read from both sides :-)
(http://weblogs.asp.net/oldnewthing/archive/2003/12/26/45979.aspx may be an
interesting read)

> >+   * @param aRequest
> >+   *        The request to dispatch as. Must be the same as passed to doContent.
> >+   *        XXX this sucks.
> 
> I rather agree....  I'm not sure what the best way to fix this is,
> conceptually.  Perhaps some verbiage indicating the overall interaction of
> nsIExternalHelperAppService and nsIDispatchable is in order?

the real solution may involve storing the request in the DocOpenInfo, but that
increases the risk of cycles...

> Do we ever enforce the latter condition?  I don't believe we do, and don't see
> a good way to do it without assuming that the current handler is always the
> externalhelperappservice.

hmm, guess we never store the uricontentlistener we chose? if we do,
DispatchContent could just compare the new one to the current one and fail if
they are equal (after CanHandleContent/IsPreferred returned true)

> This should document that it throws anytime canHandleAs is false or something
> like that.  At the very least, canHandleAs needs to be mentioned here.

will do
Comment 123 Boris Zbarsky [:bz] (Out June 25-July 6) 2004-12-22 16:40:39 PST
(In reply to comment #122)
> fine with me to make aRequest a precondition. aData is allowed to be null though
> (see the interface docs).

Why, though?  What's the use case for a null aData?

> > Could we please put this in a different file?  Especially if we expect to allow
> > embeddors to implement nsIDispatchable?
> I dunno, do we? ;) sure, fine with me. in uriloader/base or exthandler? I guess
> base is better (I envision possibly passing this to nsIURIContentListener
> objects as well, sometime in the future)

Ah, to nsIURIContentListener2?  That would make sense....

If we do plan to just keep this an exthandler-specific hack, it may be better to just expose 
that interface on aContext (basically have the object implementing the nsIDispatchable 
interface be the context, and have it forward to the original context as needed).  Then the 
interface could be in a .h file altogether or something, with all documentation in that file.

> that's the only object currently which gets an nsIDispatchable? the code would
> have to be expanded if we ever pass it to other handlers, sure. I am not sure
> that I want to give up this precondition, it seems important to let the current
> handler rely on this.

It's a good precondition, but again only one that makes sense if we plan to have multiple 
handlers that get an nsIDispatchable. If we do, then a lot of these comments make more 
sense...

> > Maybe it should?  Would that actually break anything in this case?
> I'd have to check. it probably should get onStopRequest... maybe with a special
> status code? (NS_BINDING_RETARGETED?) I suspect onstopr currently doesn't deal
> with that very well.

Special status code and dealing sounds good to me.

> I don't see how that follows... if doContent does call it, we re-enter uriloader
> while it's not done with DoContent yet. that seems scary.

Oh, I agree that it's bad.....

> I can rephrase it as "Must be called in or after onStartRequest", if you prefer that.

I think that's reasonable.  Put an assert in the URILoader code to enforce this, maybe 
(with a debug-only boolean member set across the DoContent call or something)?

> hmm, guess we never store the uricontentlistener we chose? if we do,
> DispatchContent could just compare the new one to the current one and fail if
> they are equal (after CanHandleContent/IsPreferred returned true)

It's almost worse, actually.  We want to prevent oscillatory bouncing between two 
handlers that both want to fob the load off as the type the other one handles...  So 
extending this to allowing all handlers to redispatch would have to be done pretty 
carefully.
Comment 124 Christian :Biesinger (don't email me, ping me on IRC) 2004-12-23 04:26:54 PST
(In reply to comment #123)
> Why, though?  What's the use case for a null aData?

Well, when the handler has no data... f.ex. when wanting to redispatch in
onStartRequest... (do we expect embeddors to implement nsIExternalHelperAppService?)

> If we do plan to just keep this an exthandler-specific hack, it may be better
to just expose 
> that interface on aContext (basically have the object implementing the
nsIDispatchable 
> interface be the context, and have it forward to the original context as
needed).  Then the 
> interface could be in a .h file altogether or something, with all
documentation in that file.

Hm, yeah, that's also possible. Maybe that's better for now.

> It's a good precondition, but again only one that makes sense if we plan to
have multiple 
> handlers that get an nsIDispatchable. If we do, then a lot of these comments
make more 
> sense...

This is the question... I certainly considered that case; but is it something we
really want to do?

If we want to ever replace nsIExternalHelperAppService::doContent with
nsIURIContentListener2::doContent (not saying that we want that; just a random
thought), then it does need to have some way to get at the nsIDispatchable.

> It's almost worse, actually.  We want to prevent oscillatory bouncing between two 
> handlers that both want to fob the load off as the type the other one
handles...  So 
> extending this to allowing all handlers to redispatch would have to be done
pretty 
> carefully.

ah, hmm... to prevent that, we'd need a stack of handlers (or mime types) and
ensure the new type is not in the list...


So I'll probably just use your suggestion of making nsIDispatchable available
off aContext. putting it in a .h would mean it can't be used from a
JS-implemented exthandler; do we want to support that?
Comment 125 Boris Zbarsky [:bz] (Out June 25-July 6) 2004-12-23 22:22:39 PST
> (do we expect embeddors to implement nsIExternalHelperAppService?)

I'm tempted to say "no".  We have hooks already to modify behavior; changing it 
altogether would have too many security implications to be worth supporting, I think.  We 
should just clearly document that this is an interface exposed by gecko and move 
towards freezing it, I think.... (not in the current state, though).

> If we want to ever replace nsIExternalHelperAppService::doContent with
> nsIURIContentListener2::doContent

I think this is a good goal, and when we do this we should revisit nsIDispatchable and its 
implementation with that expanded role in mind...
Comment 126 Christian :Biesinger (don't email me, ping me on IRC) 2005-03-07 16:09:28 PST
So, contrary to the above comments, I do not really want to expose this
interface on aContext... currently that's just the docshell, but if it should
expose reDispatch, I need to extend that context, probably wrap it somehow. that
doesn't seem worth the code to me. On the other hand, adding it to docshell's
list of interfaces seems wrong - getting this from a docshell is, I think, not
something we want to support.
Comment 127 Christian :Biesinger (don't email me, ping me on IRC) 2005-03-07 16:23:02 PST
Created attachment 176645 [details] [diff] [review]
backend patch, v3
Comment 128 Boris Zbarsky [:bz] (Out June 25-July 6) 2005-03-08 14:28:17 PST
Comment on attachment 176645 [details] [diff] [review]
backend patch, v3

>Index: base/nsURILoader.cpp

> +nsresult nsDocumentOpenInfo::DispatchContent(nsIChannel *aChannel,

>+    aChannel->SetLoadFlags(loadFlags | nsIChannel::LOAD_RETARGETED_DOCUMENT_URI
>                                     | nsIChannel::LOAD_TARGETED);

Fix indent of second line here?

>Index: exthandler/nsIDispatchable.idl
>+   * When this method is successful, the current handler's onStopRequest method
>+   * will be called with a status of NS_BINDING_REDIRECTED.

I don't actually see us doing this anywhere.  Did I miss something?  Should we
be calling OnStopRequest on oldListener when we reDispatch?

r+bzbarsky with these issues addressed.
Comment 129 Christian :Biesinger (don't email me, ping me on IRC) 2005-03-09 13:25:10 PST
Created attachment 176937 [details] [diff] [review]
backend patch, v4

transferring r=bz

this includes the following change for onStopRequest/NS_BINDING_REDIRECTED:
(the if for the else is if (!oldListener))
--- base/nsURILoader.cpp	8 Mar 2005 00:21:40 -0000
+++ base/nsURILoader.cpp	9 Mar 2005 21:22:09 -0000
@@ -445,7 +445,11 @@
       status = rv;

     m_targetStreamListener->OnStopRequest(aChannel, nsnull, status);
+  } else {
+    // Otherwise, send the final onStopRequest to the old listener
+    oldListener->OnStopRequest(aChannel, nsnull, NS_BINDING_REDIRECTED);
   }
+
   return NS_OK;
 }
Comment 130 Darin Fisher 2005-03-10 20:53:58 PST
Comment on attachment 176937 [details] [diff] [review]
backend patch, v4

>Index: exthandler/nsExternalHelperAppService.cpp

>+NS_IMETHODIMP nsExternalAppHandler::GetCanCallHandleAs(PRBool* aCanHandleAs)
>+{
>+  *aCanHandleAs = mDispatchable != nsnull && mApplyingDecoding;
>+  return NS_OK;
>+}

please add a comment explaining why mApplyingDecoding modifies
the value of this attribute.  also, it might read a little
better as:

  *aCanHandleAs = mDispatchable && mApplyingDecoding;


> NS_IMETHODIMP nsExternalAppHandler::OnStopRequest(nsIRequest *request, nsISupports *aCtxt, 
>                                                   nsresult aStatus)
> {
>+  if (aStatus == NS_BINDING_REDIRECTED)
>+    return NS_OK;

NS_BINDING_REDIRECTED is normally not seen by a nsIStreamListener
unless someone refused to allow a HTTP redirect through.  This
status code is seen by a loadgroup observer, however.  Do you 
maybe mean NS_BINDING_RETARGETED?  At the very least this deserves
a comment to explain what's going on.

Also, I don't think we should overload the meaning of
NS_BINDING_REDIRECTED.


>+NS_IMETHODIMP nsExternalAppHandler::HandleAs(const nsACString& aMIMEType)
>+{
>+  // Ensure that this is allowed
>+  PRBool canHandleAs;
>+  nsresult rv = GetCanCallHandleAs(&canHandleAs);
>+  if (NS_FAILED(rv) || !canHandleAs)
>+    return NS_ERROR_UNEXPECTED;

So, it is okay to call HandleAs without checking GetCanCallHandleAs?
I'm asking it because it seems to be the case that I could write code
that doesn't check but rather handles the NS_ERROR_UNEXPECTED error.


>+
>+  NS_PRECONDITION(!aMIMEType.IsEmpty() && IsASCII(aMIMEType),
>+                  "Invalid MIME Type argument");
>+
>+  nsCOMPtr<nsIChannel> channel(do_QueryInterface(mRequest));
>+  if (!channel)
>+    return NS_ERROR_NOT_AVAILABLE;

should this perhaps be checked in canCallHandleAs?


>Index: exthandler/nsIDispatchable.idl

>+/**
>+ * This interface allows re-dispatching a request to a different content
>+ * handler. It is useful to allow a user to choose to view a file as a
>+ * different type than it really is.
>+ */
>+[scriptable, uuid(69314C16-EDAD-4c9d-931C-DE2D438F9CF7)]
>+interface nsIDispatchable : nsISupports

I'm not crazy about the name of this interface.  The name suggests
that this would have a method named dispatch or something.  How
about coming up with a name that is more specific.

nsIDocumentOpenInfo is not great of course.

What it seems like to me is that you are retargeting the channel.
Maybe that is because I am necko-centric, but nsIChannel does have
a LOAD_TARGETED flag that corresponds to when a channel has a final
consumer.

Part of the problem here I think is that you are forced into exposing
this as a callback interface because of nsIExternalHelperAppService::
DoContent.  But, in reality, no one but nsURILoader.cpp should ever
care to pass a nsIDispatchable to that DoContent.  It seems to me that
consumers outside this module will instead focus on the HandleAs API.
So, it seems to me that we might be unnecessarily introducing a XPCOM
interface for communication between nsDocumentOpenInfo and 
nsExternalAppHandler.  Why not deCOMtaminate this relationship?

I'm also not fond of canCallHandleAs.  That just doesn't read well.
allowsHandleAs, permitsHandleAs, or supportsHandleAs might be better.
Comment 131 Matthias Versen [:Matti] 2005-04-20 03:42:37 PDT
*** Bug 291120 has been marked as a duplicate of this bug. ***
Comment 132 Thomas K. (:tom) 2005-05-06 01:05:41 PDT
(In reply to comment #28)
> Doesn't it make sense to display text/<unknown> as text/plain? The files on that
> page are all served as text/x-csrc. I had to save a bunch to disk and use a
> console to view them.

I'm just quoting this because it's basically what I was going to say.

Google is serving up files with text/rfc822-headers in error mails, and I would
like to have read that in the browser.
Comment 133 olecom 2005-05-17 12:09:11 PDT
Errors that this will solve are very rare and non for
ordinary users either, long fixing is proof ;-).

There're 2 issues: transfer encoding and MIME type of content.
So my proposal for GUI is here, click GUI but not use code (-:
<http://flower.upol.cz/~olecom/bugs/m-57342/nsHelperAppDlg.xul>
Note that i propose to use list of internal MIME handlers.
Also if link will be downloaded, navigators's tab or window must
not be opened at all.

Menu from that link maybe only useful if there's info about errors:
<https://bugzilla.mozilla.org/show_bug.cgi?id=11521#c25>
Comment 134 Christian :Biesinger (don't email me, ping me on IRC) 2005-05-17 14:30:16 PDT
that UI seems a bit complex...
Comment 135 Thomas K. (:tom) 2005-05-17 16:33:29 PDT
I actually think it's a pretty nice UI, the only problem is options 4 and 5
being a bit confusing.  I think it could say 
"View in Firefox as v|a web page|"
                     |plain text|"

That would be nice and easy
Comment 136 Edward Elliott 2005-05-18 10:11:24 PDT
(In reply to comment #80)
> But there *does* need to be an escape route, because the failure mode results in
> far more effort than is reasonable to work around, currently. It *should* just
> work transparently, yes, but it sometimes doesn't and in those cases it really
> doesn't need to fail that badly.

John is absolutely right.  We should be mortified that this bug is still open
after 5 years.  The user needs to be able to cope with misconfigured servers by
<a href="http://forcecontenttype.mozdev.org/screenshots.html">changing the
content type</a>.

The last 9 months of comments on this bug are an impenetrable morass of patch
discussion.  Can someone please summarize the current state of affairs?
Comment 137 Christian :Biesinger (don't email me, ping me on IRC) 2005-05-18 10:16:24 PDT
> Can someone please summarize the current state of affairs?

someone needs to update the patch per comment 130; something which I haven't yet
found the time for.
Comment 138 Edward Elliott 2005-05-18 11:57:15 PDT
(In reply to comment #137)
> someone needs to update the patch per comment 130; something which I haven't yet
> found the time for.

Thanks for the info.  Can anyone expand on that a bit?  From a user's
perspective, what will this patch accomplish?
Comment 139 Christian :Biesinger (don't email me, ping me on IRC) 2005-05-18 13:50:51 PDT
> From a user's perspective, what will this patch accomplish?

nothing. someone will also have to write UI code.
Comment 140 Edward Elliott 2005-05-18 15:19:04 PDT
(In reply to comment #139)
> > From a user's perspective, what will this patch accomplish?
> 
> nothing. someone will also have to write UI code.

Can that be done in javascript?  I'm willing to work on it, but I don't know any
internal APIs.
Comment 141 olecom 2005-05-19 06:30:35 PDT
(In reply to comment #136)
> (In reply to comment #80)
> > But there *does* need to be an escape route, because the failure mode results in
> > far more effort than is reasonable to work around, currently. It *should* just
> > work transparently, yes, but it sometimes doesn't and in those cases it really
> > doesn't need to fail that badly.
> 
> John is absolutely right.  We should be mortified that this bug is still open
> after 5 years.  The user needs to be able to cope with misconfigured servers by
> <a href="http://forcecontenttype.mozdev.org/screenshots.html">changing the
> content type</a>.
> 
> The last 9 months of comments on this bug are an impenetrable morass of patch
> discussion.  Can someone please summarize the current state of affairs?

I will _not_ install jslib on my box for it.
JS in mozilla has many bugs with linux i want to fix.
IMHO jslib is another _easy lame way_ !
External extensions maybe used only if mozilla can't handle it by itself,
so it will no forest of menus and options.

GUI ? I may do GUI in way i proposed, and it is useful but not complex.
Comment 142 Christian :Biesinger (don't email me, ping me on IRC) 2005-05-19 13:31:52 PDT
can that discussion be moved elsewhere, please...
Comment 143 olecom 2005-05-22 07:36:04 PDT
(In reply to comment #134)
> that UI seems a bit complex...

For firefox user yes ;-)
Issue with options 4 and 5 is that they propose conversion prior
to problems.

My new proposal is to move dialog with this options in "View/Show As"
menu, while adding only "new as text/plain" option in open dialog,
thus solving problems like this:
  - try to view any image from <http://www.elf.org/pnglets/>
  - <http://flower.upol.cz/~olecom/bugs/m-57342/eindex>

Comment 144 João Batista 2005-09-08 02:06:25 PDT
SUBJECT: Another user situation description.

AGENT: Mozilla 1.7.8
Mozilla/5.0 (X11; U; Linux i686; pt-PT; rv:1.7.8) Gecko/20050513 Debian/1.7.8-1

1) A "proper behavior" example.
This seems to be a problem not only of Mozilla but also of malformed server
configs. I've tryied opening directly C/C++ source code files by typing the URL
on the address bar, and the file is rendered (as expected) as text/plain. By
right-clicking the rendered text window and selecting Page Info, it reports it
is MIME type "text/plain" (not "text/x-csrc" or similar? weird...), with "Quirks
mode" rendering mode. For the time-being I have an example at
http://fisica.fc.ul.pt/~jbatista/tstamp.c

2) A "improper behavior" example.
On other examples I've seen (regretably, it's behind a firewall so it's no point
[and I've tried!] putting the URL here, sorry), even though I've explicitly
edited the HTML anchor to assign type="text/x-csrc" and even type="text/plain",
this is what happens. The browser complains it DOES NOT recognize the MIME type
text/x-csrc (i.e., it correclty identifies the MIME type...) and asks how the
file should be opened. The specific link points to a *.c file linked to by a
Tikiwiki page ( http://www.tikiwiki.org/ ), this page being generated by a PHP
script. Now, IMHO it is likely that the Tikiwiki somehow screws up the Content
Type string (if indeed one is sent).

So, IMHO it seems that if some server-side application (Tikiwiki most certainly,
some Apache configurations likely) attempts to interpret the file's contents and
send the Content Type string. However, Mozilla does not know what to do with
text/x-csrc MIMEs. On the other hand, it appears in example 1) that there was no
inclusion of a "Content Type" string in the data stream, and the stream is
identified by Mozilla as text (hence the text/plain). But I'm just theorizing
since I haven't looked into the Mozilla code...

I suppose there are ways to have a look at the data stream's content, right? How
is it done (pardon the newbie question)? If someone tells me I'm likely to try
it and post here the results, if there's interest on them.  :-)

Comment 145 Jo Hermans 2005-09-08 04:23:07 PDT
João,

the MIME-type is set by the webserver, not the browser. So it's the webserver
that chooses text/plain for a *.c file. Apache uses  the file-extension for it,
it doesn't look in the contents.

Note that Gecko gives priority to the HTTP-header 'Content-Type', not to a
META-tag. So your webpage can't override it inside the page (example 2), unless
there's a way to specify the header (user the header-function in PHP for
example, but that has to be done before the first line is printed).

Comment 146 Chapman Flack 2005-09-08 07:19:16 PDT
(In reply to comment #144)
> right-clicking the rendered text window and selecting Page Info, it reports it
> is MIME type "text/plain" (not "text/x-csrc" or similar? weird...),

That is because the server sending the file said it was text/plain.

> I suppose there are ways to have a look at the data stream's content, right?
> How is it done (pardon the newbie question)?

For this example the interesting question is simply "what type is the server
labeling this file as?"  You can check like this:

$ telnet fisica.fc.ul.pt 80
HEAD http://fisica.fc.ul.pt/~jbatista/tstamp.c HTTP/1.1
Host: fisica.fc.ul.pt

HTTP/1.1 200 OK
...
Content-Type: text/plain; charset=ISO-8859-1
Comment 147 João Batista 2005-09-08 09:46:08 PDT
(In reply to comment #146)
> (In reply to comment #144)
> > I suppose there are ways to have a look at the data stream's content, right?
> > How is it done (pardon the newbie question)?
> 
> For this example the interesting question is simply "what type is the server
> labeling this file as?"  You can check like this:
> 
> $ telnet fisica.fc.ul.pt 80
> HEAD http://fisica.fc.ul.pt/~jbatista/tstamp.c HTTP/1.1
> Host: fisica.fc.ul.pt
> 
> HTTP/1.1 200 OK
> ...
> Content-Type: text/plain; charset=ISO-8859-1

Hi Chapman,

FYI my results are below. As you can see in both cases, for which I obtain
different results, the Content-Type is the same, namely text/x-csrc. It's even
more confusing because the PHP generated the (apparently) correct HTML: I got
"<a
href="temp/4587d12e416c8ab1e8ba9b11d9d47f7c/4587d12e416c8ab1e8ba9b11d9d47f7c.C"
target="_blank" type="text/x-c++src"><p align=center>Click here to view this
ROOT C++ script's source code</p></a>" as I would expect, but the problem persists.

HOWEVER, if I change the file's name to have an extension .txt instead of .C,
then it opens with no problem...  :-o

For the first ("good") link:
--------------8<--------------8<--------------8<--------------8<--------------
$ telnet fisica 80
Trying 194.117.43.10...
Connected to fisica.fc.ul.pt.
Escape character is '^]'.
HEAD
/tikiwiki/temp/4587d12e416c8ab1e8ba9b11d9d47f7c/4587d12e416c8ab1e8ba9b11d9d47f7c.C
HTTP/0.9

HTTP/1.1 200 OK
Date: Thu, 08 Sep 2005 16:28:43 GMT
Server: Apache/1.3.33 (Debian GNU/Linux) PHP/4.3.10-15 mod_ssl/2.8.22 OpenSSL/0.9.7d
Last-Modified: Thu, 08 Sep 2005 07:51:20 GMT
ETag: "7c008-22-431fed78"
Accept-Ranges: bytes
Content-Length: 34
Connection: close
Content-Type: text/x-csrc

Connection closed by foreign host.
--------------8<--------------8<--------------8<--------------8<--------------


For the second ("bad") link:
--------------8<--------------8<--------------8<--------------8<--------------
$ telnet fisica 80
Trying 194.117.43.10...
Connected to fisica.fc.ul.pt.
Escape character is '^]'.
HEAD /~jbatista/tstamp.c HTTP/0.9

HTTP/1.1 200 OK
Date: Thu, 08 Sep 2005 16:29:03 GMT
Server: Apache/1.3.33 (Debian GNU/Linux) PHP/4.3.10-15 mod_ssl/2.8.22 OpenSSL/0.9.7d
Last-Modified: Thu, 08 Sep 2005 07:36:19 GMT
ETag: "1ec007-9f-431fe9f3"
Accept-Ranges: bytes
Content-Length: 159
Connection: close
Content-Type: text/x-csrc

Connection closed by foreign host.
$

--------------8<--------------8<--------------8<--------------8<--------------
Comment 148 Chapman Flack 2005-09-08 10:05:12 PDT
(In reply to comment #147)
I'll keep this comment brief as this issue seems to be veering OT for this bug:

> For the second ("bad") link:
> $ telnet fisica 80
> Trying 194.117.43.10...
> HEAD /~jbatista/tstamp.c HTTP/0.9
> 
> HTTP/1.1 200 OK
> Server: Apache/1.3.33 (Debian GNU/Linux) PHP/4.3.10-15 mod_ssl/2.8.22
OpenSSL/0.9.7d
> Content-Type: text/x-csrc

The curious thing here is that you've queried the same server for the same
file I queried in comment #146 and the server gave you a different content
type than it gave me.  Even more curious, a couple of lines I clipped from
comment #146 to keep it brief, but still have in my xterm:

Trying 194.117.43.10...
...
Server: Apache/2.0.54 (Gentoo/Linux) PHP/4.3.11 mod_ssl/2.0.54 OpenSSL/0.9.7e

So, we've both connected to the same IP address, but got distinctly different
servers on different machines.  I would guess fisica is doing some load sharing
among different machines behind the same outside IP, and they are configured
differently. Getting different content types for the same file on different
occasions could cause some puzzling symptoms.  But probably beyond the scope of
this bug (except as another illustration of why it would be really useful to
be able to override the declared content type when needed).
Comment 149 João Batista 2005-09-12 02:21:32 PDT
(In reply to comment #148)
> Getting different content types for the same file on different
> occasions could cause some puzzling symptoms.  But probably beyond the scope of
> this bug (except as another illustration of why it would be really useful to
> be able to override the declared content type when needed).
> 

My feelings exactly. IMHO it would be sensible to allow the user to circumvent
badly configured Web servers, by allowing the user to select an appropriate
action -- at least on those occasions that Mozilla finds out it does not know
what to do with a given MIME type.


On this note, I would vote for the UI look on comment #62 , perhaps clarifying
on those entries with the MIME type in parethesis, eg:
  (o) View as [Text    v]
              +------------------+
              | Text (plain/text)|
              | Image (image/*)  |
              | HTML (text/html) |
              | XML (text/xml)   |
              | Other...         |
              +------------------+
I'm hesitant to suggest that selected MIME types with "Other..." would show up
after being selected. E.g., if the user chose to open an URL using a MIME type
application/x-pdf, then the appropriate entry would also show up on subsequent
calls of the drop-down menu.

Comment 150 Stewart Gordon 2005-09-12 02:43:05 PDT
(In reply to comment #149)
> (o) View as [Text    v]
>               +------------------+
>               | Text (plain/text)|
>               | Image (image/*)  |
>               | HTML (text/html) |
>               | XML (text/xml)   |
>               | Other...         |
>               +------------------+
> 
> I'm hesitant to suggest that selected MIME types with "Other..." 
> would show up after being selected.  E.g., if the user chose to 
> open an URL using a MIME type application/x-pdf, then the 
> appropriate entry would also show up on subsequent calls of the 
> drop-down menu.

I'm hesitant to think we should go this far.  A reasonable start 
would be to list the formats that the browser has built in.  Listing 
plugins here might clutter it up, especially as more are added, so it 
might make sense to separate them off somehow.  And if we put the 
plugins in a separate list, how sensible would it be to have all 
installed plugins in one list?
Comment 151 Benoît 2005-09-12 04:47:31 PDT
I agree. I think we should start with the basic menu, without "Other...", and go
from there.
Comment 152 Andreas Lange 2005-09-15 02:03:00 PDT
*** Bug 308632 has been marked as a duplicate of this bug. ***
Comment 153 Jesse Ruderman 2005-10-21 16:11:36 PDT
*** Bug 313296 has been marked as a duplicate of this bug. ***
Comment 154 ferret 2005-11-08 20:17:11 PST
Apologies, I can't figure out the status of this bug from the last few posts on it. I like the sound of comment #102.  This feature seems to be being held up by implementation problems for on-the-spot user decision of what to do.  Comment #102 suggests an approach whereby a user can specify in advance what MIME types he wants to view inline always. Why can't *THAT* be implemented first (and seperately), and then when *this* finally gets done, there can be a tick box "always do this", which is the equivalent of the configuration gizmo?

In other words, why isn't there a seperate bug for what I outline above so that there is actually a way to handle the problem, for now, and stop people whining on this bug?
Comment 155 Ian Macfarlane 2005-11-16 07:06:54 PST
Why don't we just implement "View as text" first, then worry about other formats later?
Comment 156 Christian :Biesinger (don't email me, ping me on IRC) 2005-11-16 07:29:40 PST
(In reply to comment #155)
> Why don't we just implement "View as text" first, then worry about other
> formats later?

? that doesn't make any difference in terms of development effort.
Comment 157 Christian :Biesinger (don't email me, ping me on IRC) 2005-12-12 13:53:16 PST
*** Bug 319974 has been marked as a duplicate of this bug. ***
Comment 158 Peter Clay 2006-01-23 03:49:05 PST
I've found that creating a MIME handler of:

mozilla -remote 'openFile(%s)'

does pretty much exactly what I want. Surely it can't be that hard for someone who knows the codebase to implement that internally?
Comment 159 Jesse Ruderman 2006-05-13 19:53:36 PDT
Security consideration: Gmail appears to use content-disposition: attachment to prevent HTML attachments from being used in XSS attacks.  We should avoid breaking that if we add this feature.
Comment 160 Vincent Lefevre 2006-05-14 11:47:43 PDT
(In reply to comment #159)
> Security consideration: Gmail appears to use content-disposition: attachment to
> prevent HTML attachments from being used in XSS attacks.  We should avoid
> breaking that if we add this feature.

Concerning content-disposition, see bug 185618. But not taking content-disposition into account is the right way, as it is a non-standard header, which should thus be ignored (though a different behavior could also be chosen as an option). If Gmail is based on such a non-standard feature for security consideration, then it is highly broken.
Comment 161 Jesse Ruderman 2006-05-14 21:02:28 PDT
Content-disposition is described in http://www.faqs.org/rfcs/rfc2183.  It is also mentioned in the "Security considerations" section of the HTTP spec (http://www.faqs.org/rfcs/rfc2616), although it's not clear what security considerations it's talking about.

Btw, I'm not sure I agree with the way you equate "non-standard" with "wrong".
Comment 162 Vincent Lefevre 2006-05-15 01:49:45 PDT
(In reply to comment #161)
> Content-disposition is described in http://www.faqs.org/rfcs/rfc2183.  It is
> also mentioned in the "Security considerations" section of the HTTP spec
> (http://www.faqs.org/rfcs/rfc2616), although it's not clear what security
> considerations it's talking about.

The security considerations concern the directory path information. I've mentioned it in bug 185618 comment 45.

Concerning this bug 57342, whose goal is to be able to view the contents for unsupported media types, there's nothing to save, therefore no security problems.

> Btw, I'm not sure I agree with the way you equate "non-standard" with "wrong".

When a non-standard feature modifies the normal behavior documented in standards (in a non-optional way), this is a bug.
Comment 163 Timwi 2006-05-15 15:17:30 PDT
> Btw, I'm not sure I agree with the way you equate "non-standard" with "wrong".

I'm not sure I agree with the hidden implication that something is "right" just because Gmail does it.
Comment 164 Sylvain Pasche 2006-06-18 16:23:07 PDT
For those who can't wait for this to be implemented, I've made an extension to open documents in browser. It is a kind of hack, but it can make life easier for some people:

http://www.spasche.net/mozilla/
Comment 165 Matthieu MOY 2006-06-19 03:10:22 PDT
The extension is great. Just what I was looking for !!

Thanks !
Comment 166 db 2006-06-23 14:22:42 PDT
Great extension. Do you think you could add application/pdf to its known MIME-types?
Comment 167 Sylvain Pasche 2006-06-23 14:38:55 PDT
(In reply to comment #166)
> Great extension. Do you think you could add application/pdf to its known
> MIME-types?

That could be added to the feature list.

Please use the mozillazine forum (http://forums.mozillazine.org/viewtopic.php?t=430010) for such requests, as this is outside of the topic of this bug. Thanks

Comment 168 M 2006-10-22 04:53:43 PDT
I have been using the extension of Sylvain (http://www.spasche.net/mozilla/) for a while now, and indeed, it is great.

However, this is basic browser functionality and should NOT be a custom extension. All it does is make the browser behave as it always should have, and as Opera has done since at least version 3.5 (!).

Please incorporate this extension or it's functionality into the standard browser code!
Comment 169 Vincent Lefevre 2006-10-22 10:44:07 PDT
(In reply to comment #168)
> Please incorporate this extension or it's functionality into the standard
> browser code!

I agree. I think this is important, not just for Firefox users, but for the web in general. Indeed an extension is not sufficient, otherwise many users won't be able to see text/* files by default, meaning that web authors will give an incorrect media type to source files, just to be compatible with Firefox.

Could this block the next Firefox version?
Comment 170 Eyal Rozenberg 2006-10-22 11:04:47 PDT
(In reply to comment #169)
> Could this block the next Firefox version?

Maybe if there's an unrejected patch against the trunk... either based on the extension or the previous patch. Otherwise, not really. Unfortunately.

Comment 171 Benoît 2006-10-23 03:32:56 PDT
Did it ever dawn on you that this is a Gecko bug? A lot of other applications benefit from Gecko too, not just Firefox.
Comment 172 Jo Hermans 2006-11-15 14:10:46 PST
*** Bug 360817 has been marked as a duplicate of this bug. ***
Comment 173 Sylvain Pasche 2006-11-16 15:03:17 PST
*** Bug 360979 has been marked as a duplicate of this bug. ***
Comment 174 Sylvain Pasche 2007-01-26 04:14:40 PST
Created attachment 252899 [details] [diff] [review]
Toolkit ui hack for testing
Comment 175 Sylvain Pasche 2007-01-26 04:18:36 PST
Created attachment 252900 [details] [diff] [review]
backend patch, v4 updated

This is an update of the latest patch against trunk. It does not address Darin's comments yet. As one could expect, it did not apply cleanly, so I had to manually merge some stuff.

I had not much success with this new patch applied: If I select for instance text/html for the mime to redispatch, I'm getting assertion:

###!!! ASSERTION: nsExpatDriver didn't get an nsIExpatSink: 'Error', file /[...]/mozilla/parser/htmlparser/src/nsExpatDriver.cpp, line 1180

Then the originating window is staying in loading state (the spinner is running), and if I click on the window, I can see the assertions:

WARNING: NS_ENSURE_TRUE(aPresContext->Document()->GetWindow()) failed: file /[...]/mozilla/content/events/src/nsIMEStateManager.cpp, line 174

When stepping inside the nsDocumentOpenInfo::ReDispatch function, I can see that the 
m_targetStreamListener->OnDataAvailable() call is failing and is in the callstack when the nsIExpatSink assertion is thrown.

If you have any hints about this, they are welcome.
Comment 176 Sylvain Pasche 2007-01-28 14:08:54 PST
The issue comes when nsDocumentOpenInfo::ReDispatch is called after the initial request is finished (OnStopRequest called).

In that case, the call to aChannel->SetContentType(aMIMEType) in nsDocumentOpenInfo::ReDispatch does not change the content type, as the channel has no listener any more. Because the content type did not change, the parser thinks it is XML, that's why we saw expat exceptions.

I tried to hack nsHttpChannel::SetContentType to force setting the content type, even when it has no listeners. That fixes the expat assertion and the page displays, but the spinner keeps running and there's some assertions appearing:

-1610559552[2307150]: WARNING: NS_ENSURE_TRUE(aPresContext->Document()->GetWindow()) failed: file /[...]/mozilla/content/events/src/nsIMEStateManager.cpp, line 174
-1610559552[2307150]: ###!!! ASSERTION: win is null.  this happens [often on xlib builds].  see bug #79213: 'Error', file /[...]/mozilla/content/events/src/nsEventStateManager.cpp, line 957

If Redispatch is called while the request is not finished, things seem to be working better (spinner stop running after page is finished). I used the following useful URL for testing:
http://www.hixie.ch/tests/evil/page-loading/incremental/001.cgi
Comment 177 :Gavin Sharp [email: gavin@gavinsharp.com] 2007-06-03 11:18:48 PDT
*** Bug 383037 has been marked as a duplicate of this bug. ***
Comment 178 Denis Kasak 2007-11-07 09:21:31 PST
Any news on this bug? It's been some time since the last post.
Comment 179 Robert Rothenberg 2007-12-06 07:50:48 PST
This is a very useful and common-sense option, which I'd like to see fixed inside the browser. I'm annoyed with trying to view text files that have alternative MIME types (e.g. LaTeX) by launching the editor.  

The "Open in browser" extension doesn't work all the time, and this is something so simple that it should just be a care part of the browser.
Comment 180 Boris Zbarsky [:bz] (Out June 25-July 6) 2008-05-15 16:55:35 PDT
We should really find someone to drive this in...  I can try to do it, but then I need to find someone else to review the whole thing.
Comment 181 JDev 2008-11-06 07:02:31 PST
I was a little shocked when I reported bug 463361 to discover it had been around in one form or another since 2000.

Why is it that it cannot be as simple logic as "if open url triggers download code && firefox.exe is the application associated, dump as text to screen".  Something this simple could also be expanded later to handle some of these other related bugs.  "If mime type x == associated to firefox.exe do-> some method else dump as text".  Inserting call to extension or internal code set at "some method"

This would prevent the infinite loop problem and allow for extendability.
Comment 182 Jason Duell [:jduell] (needinfo? me) 2009-01-16 11:23:36 PST
Assigning to myself, the hapless new necko maintainer.  This does look like a good bug to finally fix, so it looks like it will be high on my list.
Comment 183 joseph 2009-04-23 05:47:06 PDT
Now when you read my comments, I want you to take them on board, because I speak for the whole firefox users community. And if you decide to take offence, then thats tough, but I am writing it like I feel it because I am ANGRY AND ANNOYED.

Bugs like these should have been resolved a long time ago and I complained about this way back when firefox was still in it's infancy and some stupid sod deleted the bug entry and back then I was as polite as hell and even offered some advice.

My complaint is that jpeg files won't just open in firefox, even though they can and are opened in firefox when I tell the stupid dialog box to just open the damned thing in firefox. And yes I have set firefox as the default handler for jpeg files and no the file isn't cymk.

I can't believe how lazy you people can be.

A bug that has been around for 9 years and not one can fix it. Says a lot for your programming skills eh.

Can't you people see how you are just turning people away from firefox.

I personally am testing Opera and once I get to grips with it's ins and outs, I will be switching over to that because I am so fed up of all the lousy bugs that have never been fixed in firefox and the way your company is just becoming a smaller version of microcrap.

Most of these dammed files can be and eventually are viewed in firefox, so why can't someone just program the damned program to just open them in firefox without having to put us all through the nonsense of the save as dialog box.

Personally, i think you lot should be ashamed of yourselves, especially since there are many more bugs that have been around for ages.

But, if you bunch of lazy sods want firefox to die, then on your own heads be it.

And when I say LAZY I damn well mean lazy.

ANd yes I am bloody angry that this and the many other bugs STILL HAVEN'T BEEN RESOLVED.
Comment 184 Ali Ebrahim 2009-04-23 06:30:12 PDT
To comment 183, I think I speak for the "whole firefox users community" when I say "Goodbye, and good riddance."

To everyone else, sorry for bugspam, I couldn't resist...
Comment 185 JDev 2009-04-23 17:59:59 PDT
Indeed - if you were so upset you should have taken those nine years to patch it yourself!  This is a community of volunteers after all.  

Thank you to everyone who has contributed to this.
Comment 186 Eyal Rozenberg 2009-04-23 23:24:45 PDT
With due respect to commenters 184 and 185:

Users are certainly justified in being upset about relatively simple high-visibility bugs like this one not being fixed. Commenter 183 may have gone overboard, but he has been bottling it up for 9 years after all... So, no, it's not "Goodbye and good riddance".

Also, Firefox is not now the product of a community of volunteers, but rather mostly of a group of salaried programmers, with much financial backing from Google (if not as much as one would expect given the circumstances). That group can be expected to satisfy certain user needs, such as having this bug resolved. Even Google itself can be expected to have them satisfied. And, finally, why do some people assume everyone can code at all, not to mention get a handle on a huge project like  Firefox enough to be able to fix such a bug? A tiny tiny minority of users have the skills and the time to do so.

Sorry for the bugspam.
Comment 187 scientus 2009-04-23 23:35:11 PDT
Ill apologize in advance for morebug spam on this.

I do definitely think this bug should be fixed, and that it is way overdue. I do not discredit someone who gets **** over being mad at the status either. However I would like to point out that there is a workaround for this bug.

1) copy the link (right-click --> "copy link location")
2) clear the address bar (ctrl-l)
3) type "view-source:" and then paste in the url (ctrl-v)
3) enter

However IMHO this is inadequate, and the bug should still be fixed as described.
Comment 188 joseph 2009-04-24 19:05:57 PDT
With regards to Marks comments (Comment #185) I am not a software programmer. I design web sites and if ever I have encountered problems similar to this, I have always taken the time to resolve them, both to the customers satisfaction and because I take pride in my work. If you are a firefox programmer Mark, then you are one of those people who are to blame for the eventual demise of firefox and I hope that one day this realisation will hit you fully and that it may do so in a way which will force you to see how crass and childish your comments are.

As mentioned above (Comment #186 From  Eyal Rozenberg) Firefox is owned by a huge corporation with so much money that it can afford to fix such annoying problems and the fact that even after complaining about this bug and having my original complaint, first dismissed as stupid (and said to be my fault, because apparently I didn't understand how web browsers work) and secondly when it was deleted with no reasons given for the deletion, simply shows how such huge corporations disrespect their users and prioritise their own aims before those of the people who actually use their products.

I would also like to add that I supported firefox from the day I discovered it, this after being an avid fan of IE for many years. Then I started web design, after which I discovered the shortcomings of IE and from that day, through my various web sites and through word of mouth, I have convinced many people to switch to firefox in the belief that here was a web browser being developed by ordinary people for ordinary people.

Marks comments above illustrate exactly the kind of attitude which puts users off badly programmed software and this is just an additional reason for my looking to switch over to Opera.

Additionally, I dislike the fact that over the years I have seen many good ideas and suggestions for improvements to Firefox dismissed as unecessary, or too time consuming and I do not think that I want to be a part of a project which does not accept new ideas, or innovations as seriously as it should.

I still have to use firefox for development purposes and I will admit that I think it has a lot of great functions which are missing from most of the other browsers and that I will miss it and the firefox community.

I wish you all the very best for the future and hope that someone who takes pride in their work eventually resolves this problem, but sadly, I do not think that I will be a firefox user long enough to see that day.
Comment 189 Robert Rothenberg 2009-04-25 05:14:09 PDT
Apologies in advance for more bugspam, but I have some additional points to make:

(In reply to comment #183)
> Now when you read my comments, I want you to take them on board, because I
> speak for the whole firefox users community....

Actually, you don't.

> Bugs like these should have been resolved a long time ago ...

Why should the bug have been resolved a long time ago? It's not affecting most users, not causing systems to crash, deleting data, etc.?  At most it's an annoyance with a workaround (and perhaps a plugin). 

Indeed, if you read the history of the bug, it wasn't initially clear *how* to fix it. The Add "View as..." option came about after some discussion.

And while it seems simple to fix for a non-programmer, web browsers are complex. There are still a couple of bugs that this bug depends on.
 
> My complaint is that jpeg files won't just open in firefox, even though they
> can and are opened in firefox when I tell the stupid dialog box to just open
> the damned thing in firefox. And yes I have set firefox as the default handler
> for jpeg files and no the file isn't cymk.

Whoa! That's a different bug altogether.  So file a different bug.  And give useful details, like what operating system, and links to or attachments of example jpeg files that are problematic.
 
> I can't believe how lazy you people can be.

No, just busy with more important things.

> A bug that has been around for 9 years and not one can fix it. Says a lot for
> your programming skills eh. ...

"You catch more flies with honey than vinegar."
Comment 190 Timwi 2009-04-25 15:02:32 PDT
> Additionally, I dislike the fact that over the years I have seen many good
> ideas and suggestions for improvements to Firefox dismissed as unecessary, or
> too time consuming and I do not think that I want to be a part of a project
> which does not accept new ideas, or innovations as seriously as it should.

Yes, but this is nothing new. This is a general property of the open-source development model which is not going to improve soon. (http://mpt.net.nz/archive/2008/08/01/free-software-usability, see point #3)
Comment 191 joseph 2009-04-26 02:45:24 PDT
Robert Rothenberg, you and small minded people like you, must enjoy picking apart peoples comments as opposed to fixing bugs.

When i say I speak for the majority of firefox users, I actually because as mentioned in my previous post I have lots of customers and friends and family to whom I recommended firefox and they too encounter the same problem and the only reason they do not complain is because they are not technically minded, or do not feel confident enough discussing such matters, as do most ordinary firefox users.

Bugs like these should have been resolved a long time ago because as mentioned, I reported this very same problem over 7 years ago and again as mentioned in my previous post, it was deleted and another egotistal programmer simply dismissed it and deleted the bug I reported.

With regard to this bug not being the same bug, it might not be, but no one else has protested about it and it is a mime type bug which has the same kind of problem as the other file types mentioned here.

It is affecting users and whilst it does not crash tthe browser, we users don't want to waste our time clicking on silly dialog boxes because of faulty  functionality which LAZY programmers like you cannot be bothered to fix because you want to go watch porn or whatever you call important.

I too have done some programming and I know that problems like these arise from bad coding practices which haven't been corrected. BTW this features works fine in every other web browser that I have used and I don't need to click on a single dialog box to view a jpeg file (as opposed to a jpg file). Now if you consider that unimportant then obviously you don't have the intellectual capacity to grasp what I am saying.

Using stupid qutoes doesn't alter the fact that this BUG has been around for as long as firefox has been in existence and well, if you cannot be bothered to fix such problems, then obviously you can't be all that good a programmer, so what the hell are you doing being involved in such a project if its beyond your capabilities.

People with attitudes like yours should not be involved in projects like these because your incompetance causes mroe problems in the long run and the manifestation of that is a long list of faults which we users have had to endure, but no more thanks to opera. And I think that the 100's of thousands of readers of my web sites will agree with me, especially when I post your comments on my web sites, so they can see exactly how some firefox programmers instead of accepting constructive criticism, cry like a little baby and try to bad mouth their users.

One final word. If you cannot tolerate constructive criticims by a firefox user of long standing then I suggest you go back and hide under your mummys apron because all I have done is to express my anger and frustration at a bug which as mentioned I reported long ago and which nothing has as yet been done about.
Comment 192 Robert Rothenberg 2009-04-26 03:28:43 PDT
Again, apologies for the bugspam....

(In reply to comment #191)
> Robert Rothenberg, you and small minded people like you, must enjoy picking
> apart peoples comments as opposed to fixing bugs.

Insulting people who do not agree with you will get you nowhere.

> When i say I speak for the majority of firefox users, I actually because as
> mentioned in my previous post I have lots of customers and friends and family
> to whom I recommended firefox and they too encounter the same problem ...
> ...
> With regard to this bug not being the same bug, it might not be, but no one
> else has protested about it and it is a mime type bug which has the same kind
> of problem as the other file types mentioned here....

Again, provide technical details about the bug (URLs, browser versions, operating system versions, etc.), so that it can be diagnosed, rather than ranting about how there is a problem that no one is fixing.

It doesn't seem to affect that many users. From your description, it seems to affect YOUR clients, so perhaps it is something YOU are doing: is the webserver returning the appropriate MIME type for the JPEG files?

> BTW this features works fine
> in every other web browser that I have used and I don't need to click on a
> single dialog box to view a jpeg file (as opposed to a jpg file). Now if you
> consider that unimportant then obviously you don't have the intellectual
> capacity to grasp what I am saying.

That could also mean that Firefox is behaving correctly and the other browsers are poorly implemented and ignoring an error.

> One final word. If you cannot tolerate constructive criticims ...

Your criticisms have not been constructive at all. They have been insults.

If you want to be constructive, provide some useful information about the specific problem you are having.
Comment 193 :Aryeh Gregor (away until August 15) 2009-04-26 05:33:23 PDT
Could the people who should know better please stop saying "Sorry for the bugspam, but . . ." and then spamming everyone?  If your sense of indignation at this user is such that you can't stand letting his claims go un-rebutted, try replying by e-mail.

(And yes, I'm not practicing what I preach, but several different people have been doing this here so far and probably more will even if I privately e-mail everyone who's done it so far.)
Comment 194 Reed Loden [:reed] (use needinfo?) 2009-04-26 06:19:06 PDT
I'd like to take this chance to remind everybody commenting lately of the Bugzilla Etiquette (https://bugzilla.mozilla.org/page.cgi?id=etiquette.html) that governs this Bugzilla instance. Most of the recent comments in this bug have been in violation of one or more points in the Etiquette, and recent activity has started to generate a lot of complaints.

Please do not comment in this bug unless you're discussing how best to fix this bug, attaching a patch to fix it, or are doing sometime actually useful rather than making pointless bugspam that doesn't help anything. This is your *only* warning. Any future violations of the Bugzilla Etiquette will result in the disabling of the violating Bugzilla accounts. Bugzilla is not a forum for such comments. If you wish to rant, the newsgroups are the appropriate place for such comments, not Bugzilla. Again, this is your *last* and *only* warning.

Thank you for your time.
Comment 195 O. Atsushi (Torisugari) 2009-04-27 03:09:25 PDT
Basic designs are not solid, yet.

The problem is that users can close the original window (or tab) before
choosing some option in external-app dialog. This could causes multiple
bad results. It's okay to open it in a new tab, please think about such
a link:

<a href="unknown_mime.txt" target="my_target"> See the target. </a>

In this case, user may close "my_target" window before loading any
content into it. Gecko should force to open a new window nonetheless,
on user chosing "Handle inside Gecko"?

In summary, I think external-app window should be a modal dialog. Or
it needs a way to protect original DOM window, such as overlapping
bar or something like that.
Comment 196 O. Atsushi (Torisugari) 2009-04-27 03:28:50 PDT
Created attachment 374753 [details] [diff] [review]
PoC modal dialog

Proof of concept.

You can see how simple the patch will be, if external-app dialog were modal.
And probably less buggy.

I don't think simpleness beats usability, as I get annoyed even with 
HTTP password prompt. But, in my opinion, keeping it modeless is difficult,
for very the same reason why we don't have modeless password prompt.
Comment 197 zug_treno 2009-07-02 09:43:22 PDT
*** Bug 497445 has been marked as a duplicate of this bug. ***
Comment 198 Bryan Taylor 2009-07-15 14:26:48 PDT
Jason Duell, this has been assigned to you for almost six months. What is it about this bug? Why does it never get solved? I'm not asking to bitch, I just don't understand why it takes nine years to display files. The techncial solution has existed for three years as an addon: 

https://addons.mozilla.org/en-US/firefox/addon/8207

While this bug is clearly not a data loss or security issue. I'm sure there are a few bugs out there that deserve higher priority. But as a user of firefox, my impression of 95% of the things that do get worked is that they should not have been chosen over this one. The addon above has demonstrated a viable technical solution, and has existed for three years. How about implementing it as is? If there are criticisms of it, how about implementing it anyway and dealing with improving it later?

It's fascinating how certain bugs like this one can have some kind of "group think" where a zombie like mental paralysis seems to descend and prevent common sense from prevailing. I'm not interested in denials, rebuttals, excuses, explanations. I just want to open files in my browser without having to install the "don't suck" addon.
Comment 199 Jesse Ruderman 2009-07-15 15:05:49 PDT
I'm curious how the extension avoids the security issues that a naive implementation would have.
Comment 200 Jesse Ruderman 2009-07-15 15:56:10 PDT
I filed bug 504441 for the security parts, which will probably want to be a separate patch anyway.
Comment 201 Sylvain Pasche 2009-07-15 16:38:26 PDT
(In reply to comment #199)
> I'm curious how the extension avoids the security issues that a naive
> implementation would have.

Just to clarify, the extension doesn't protect users from malicious scripts when viewing documents as html. I'll see if I can do something like bug 504441 inside the extension, or maybe show a warning when viewing a mime type that runs scripts.

By the way, I noticed that Opera 10 doesn't protect the user from these kinds of security issues.
Comment 202 Andy Willis (abwillis) 2010-01-01 09:02:18 PST
I am not sure if this is still an issue but initially it seemed the technical issues involved were that there was no way to get back to the browser from the helper application.  How about a different approach?  I propose no UI but rather only have an option in about:config.  
I am not sure of the correct section but something like:
browser.display_alltext_as_plain   
default would be FALSE and exhibit current behavior but if changed to TRUE the browser just treats it as text/plain and never takes the external handler path.
Comment 203 John Sullivan 2010-01-05 11:30:06 PST
(In reply to comment #202)
> issues involved were that there was no way to get back to the browser from the
> helper application.  How about a different approach?  I propose no UI but

Presumably the bit of code *within* firefox that deals with external helpers, since before the user has dismissed the unknown type dialog, the actual external helper can't possibly exist.

> rather only have an option in about:config.  
> I am not sure of the correct section but something like:
> browser.display_alltext_as_plain   

1) Even for types that look like plain text, I might not want this all the time. Sometimes I really want to view source code with an oddly specific mimetype in firefox with minimal fuss. Sometimes I happen to know the server is going to spew 50MB of ASCII machine logs out and really want it to go directly to the helper rather than wedge the layout engine for a minute.

2) This isn't a text-only issue. Only today I had firefox pop the dialog for a PNG image that was presumably incorrectly tagged. As I've pointed out before, the truly crazy thing is you can select firefox as the external helper and it will dutifully write it out to disk, launch firefox externally on the file, presumably it then uses dbus/DDE/some other equivalent method to pass the file back to the original firefox instance which then displays it just fine. However you've lost the original HTTP session context there: refreshing won't reload and certain other things look/behave differently. The final solution (ignoring any necessity of a dialog for user choice in the matter) should end up behaving exactly as if firefox had known what to do from the beginning.
Comment 204 Vincent Lefevre 2010-01-05 12:23:46 PST
(In reply to comment #203)
> 1) Even for types that look like plain text, I might not want this all the
> time. Sometimes I really want to view source code with an oddly specific
> mimetype in firefox with minimal fuss. Sometimes I happen to know the server is
> going to spew 50MB of ASCII machine logs out and really want it to go directly
> to the helper rather than wedge the layout engine for a minute.

This can also happen with text declared as text/plain, or even HTML.
Comment 205 flying sheep 2011-05-10 08:14:11 PDT
the extension „open in browser“ doesn’t work on local files (offering only „view source“)

the solution should work on those, too.
Comment 206 Michal 'hramrach' Suchanek 2011-05-10 10:59:55 PDT
(In reply to comment #201)
> (In reply to comment #199)
> > I'm curious how the extension avoids the security issues that a naive
> > implementation would have.
> 
> Just to clarify, the extension doesn't protect users from malicious scripts
> when viewing documents as html. I'll see if I can do something like bug
> 504441 inside the extension, or maybe show a warning when viewing a mime
> type that runs scripts.
> 
> By the way, I noticed that Opera 10 doesn't protect the user from these
> kinds of security issues.

Nor does Firefox, on any content that is HTML from the start or relabeled as such by the extension.
Comment 207 Shad Sterling 2012-10-18 21:57:50 PDT
I suggested a more general solution in bug 185618 comment 61 (about adding an option to render content in Firefox whenever "Save As" comes up immediately).

I suggest using an error/info page for content of a type for which there is no handler or for content for which the handler fails, so anytime Save As comes up there is some content behind it.  In the case of an unknown type, the error/info page would appear as a placeholder, which would prevent unknown types from cutting off user activity, and make room for a separate "Reinterpret Content" sheet with which the user could override the provided content-type to one which Firefox can render.
Comment 208 Sergio Basto 2013-11-25 07:12:50 PST
I need "open in browser" working ! , I hope this is not another stupid security reason
Comment 209 Alexander Stohr 2013-11-26 04:56:05 PST
i am using Waterfox 24.0 (64 bit build version of firefox) on Windows 7 x86 64 bits.

when visiting this page: http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/tirtos/1_10_00_23/index_FDS.html
(might require a free account to view or download)
and downloading the windows version (*.exe) of the file set
then i can select any option for opening or saving including the "remember my decision" option.

but when going for the linux version i only get offered two options: open with an application (default here is VLC) or download but the "remember" button is grayed out.

for my impression the browser should be able to remember decisions for explicitly html/mime tagged file formats as already realized. but for for non-tagged or "wildcard"-tagged files and it shall be check for the file name extension (or absence of such an extension - this happens more often than you would think) and decide based upon that extension. so the browser needs not only a mime type default action configuration database/listing but an extension based handling if mime type is not that useable. maybe even the user can pass down certain mime types to the extension based treatment. thus the mime type layer should see a new option: "handle by file extension".

@Sergio - thats a nice proposal in that area. i can support that. its all about options.

BTW i think the dialog does not mention the mime type so i am a bit lost in diagnostics for that my faulty cases using purely the browser. the dialog should mention the mime-type he asks me about.
Comment 210 Alexander Stohr 2013-11-26 05:11:06 PST
Created attachment 8338461 [details]
screenshot of browser file reception dialog that has a grayed out "remember" item
Comment 211 Andrew Church 2013-11-26 05:38:58 PST
@Alexander: This bug is about adding a "View as text/HTML" option, not about the "do this automatically" checkbox.  Try looking at bug 453455 or bug 561392 instead.
Comment 212 Anli Shundi 2014-07-14 07:45:03 PDT
I see parity-opera tag -- you can add chrome as well.  Content-Type: text/x-java-source are displayed there automatically as text whereas in FF I can only open with another app or save.
Comment 213 Stewart Gordon 2014-07-14 14:58:11 PDT
But can Chrome view arbitrary unknown MIME types as text, or just text/* types, or does it just know about some specific MIME types such as this?
Comment 214 Vincent Lefevre 2014-07-14 17:06:52 PDT
Even if Firefox was improved to support unknown text/* types (viewed as text/plain), this would be a great improvement. Almost all files that I can't view directly in Firefox due to this bug have a text/* type.
Comment 215 Frankie 2015-01-24 08:06:52 PST
*** Bug 578990 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.