Option to display file in browser, treat as text/plain

Bug #25830 reported by Martin Flack
40
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Mozilla Firefox
Confirmed
Unknown
firefox (Ubuntu)
Triaged
Wishlist
Unassigned

Bug Description

A suggestion:

When you click certain files, like .py or .pl files, for example, Firefox brings
up a dialog that offers you the ability to:
1. Open with a certain application
2. Save to disk
What would be nice is a third option:
3. Treat as text/plain

The wording could be altered... "Display as text in browser" or something.

Sometimes you just want to quickly visit a file on the web and look for
something in it, and the fact that you *could* open it in a more customized
application is true but not really easier for you at that moment. If you just
want to look a Python script for a version number at the top it is not necessary
to open it in your IDE or save it to disk; you just want to open it in the
normal viewing window as plain text and quickly find what you need to look at.

Revision history for this message
In , Leger-formerly-netscape (leger-formerly-netscape) wrote :

Updating QA Contact.

Revision history for this message
In , Don-formerly-netscape (don-formerly-netscape) wrote :

Move to M20.

Revision history for this message
In , Paulmac (paulmac) wrote :

updating qa contact

Revision history for this message
In , Don-formerly-netscape (don-formerly-netscape) wrote :

Move to "Future" milestone.

Revision history for this message
In , Asa (asa) wrote :

*** Bug 47415 has been marked as a duplicate of this bug. ***

Revision history for this message
In , pohl (pohl-longsine) wrote :

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.

Revision history for this message
In , Asa (asa) wrote :

over to XPApps

Revision history for this message
In , Gervase Markham (gerv-mozilla) wrote :

<email address hidden> - 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

Revision history for this message
In , pohl (pohl-longsine) wrote :

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.

Revision history for this message
In , pohl (pohl-longsine) wrote :

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.

Revision history for this message
In , Vishy (vishy) wrote :

Since Don has left, Vishy is taking his bugs in bulk, pending reassignment.
thanks,
 Vishy

Revision history for this message
In , Bugzilla-iwaruna (bugzilla-iwaruna) wrote :

pardon the spam: reassigning these remaining xp apps bugs of don's to vishy for
the time being. hope that's okay!

Revision history for this message
In , Verbal-myrealbox (verbal-myrealbox) wrote :

Changed summary. Marking as NEW so someone will either mark it as WONTFIX or
INVALID.

Revision history for this message
In , pohl (pohl-longsine) wrote :

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".

Revision history for this message
In , Paulkchen (paulkchen) wrote :

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-

Revision history for this message
In , Paulkchen (paulkchen) wrote :

nav triage team:

Too much work to support translation between media types and do it well, not
going to get to this for beta1, marking nsbeta1-

Revision history for this message
In , Jps (jps) wrote :

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.

Revision history for this message
In , Sfraser-bugs (sfraser-bugs) wrote :

Does the underlying functionality exist? Editor needs to be able to tell .js
files to be loaded as text, for example, so that we edit them like text files
(since they are UTF-8 and many text editor can't deal with that).

How hard would it be to override the document's MIME type some time early in the
loading process?

Revision history for this message
In , Matty-is-a-geek (matty-is-a-geek) wrote :

Can someone in the know say if there is anything here that requires API changes
that should be nominated as needing to be in before Mozilla 1.0?

Revision history for this message
In , Benc-frame (benc-frame) wrote :

This would be a very useful feature, because (shamefully), it would make it
easier for http server administrators to verify they selected the right MIME
type w/o repeatedly reconfiguring their server...

Revision history for this message
In , Paulkchen (paulkchen) wrote :

Marking nsbeta1- bugs as future to get off the radar

Revision history for this message
In , Jps (jps) wrote :

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!

Revision history for this message
In , Jps (jps) wrote :

Another thing: should this be assigned to <email address hidden> (Boris Zbarsky)
since he is working on bug 52441?

Revision history for this message
In , Jps (jps) wrote :

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!

Revision history for this message
In , Timeless-bemail (timeless-bemail) wrote :

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.

Revision history for this message
In , Bzbarsky (bzbarsky) wrote :

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?

Revision history for this message
In , Matthew Paul Thomas (mpt) wrote :

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...))

Revision history for this message
In , Timeless-bemail (timeless-bemail) wrote :

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 ...?]

Revision history for this message
In , Matthew Paul Thomas (mpt) wrote :

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

Revision history for this message
In , Bzbarsky (bzbarsky) wrote :

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...

Revision history for this message
In , Bzbarsky (bzbarsky) wrote :

*** Bug 87301 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Robbe (robbe) wrote :

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.

Revision history for this message
In , Benc-meer (benc-meer) wrote :

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.

Revision history for this message
In , Jps (jps) wrote :

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 <email address hidden>
(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

Revision history for this message
In , Robbe (robbe) wrote :

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.

Revision history for this message
In , Tpowellmoz (tpowellmoz) wrote :

*** Bug 100080 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Matthew Paul Thomas (mpt) wrote :

*** Bug 95028 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Matti-mversen (matti-mversen) wrote :

*** Bug 125847 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Jmd (jmd) wrote :

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.

Revision history for this message
In , Jmd (jmd) wrote :

Fixing summary or I'll never be able to find this bug again.

Revision history for this message
In , Bzbarsky (bzbarsky) wrote :

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.

Revision history for this message
In , Bzbarsky (bzbarsky) wrote :

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...

Revision history for this message
In , Jps (jps) wrote :

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.

Revision history for this message
In , Jruderman (jruderman) wrote :

*** Bug 21985 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Matti-mversen (matti-mversen) wrote :

*** Bug 142451 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Jruderman (jruderman) wrote :

-> file handling

Revision history for this message
In , Jruderman (jruderman) wrote :

*** Bug 144219 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Bzbarsky (bzbarsky) wrote :

*** Bug 144960 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Matti-mversen (matti-mversen) wrote :

*** Bug 156487 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Jonasj-qio (jonasj-qio) wrote :

*** Bug 156788 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Dmose (dmose) wrote :

Given that Vishy's no longer working on Mozilla, perhaps bz or law would like
this one...

Revision history for this message
In , Bugzilla-blakeross (bugzilla-blakeross) wrote :

Reassigning to a real person.

Revision history for this message
In , Griswold-acm (griswold-acm) wrote :

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.

Revision history for this message
In , Jmd (jmd) wrote :

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.

Revision history for this message
In , pohl (pohl-longsine) wrote :

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.

Revision history for this message
In , Piotr-t-p-l (piotr-t-p-l) wrote :

(continuation/addition to my bug that as a dupe of this)
this bug is really obnoxious on scripted redirects .. like download trackers ..
because save link as saves it as the tracker file .. ie .. tracker.cgi instead
of myfile.rar .. I know this mostly is a server side issue and all .. but this
is getting me really annoyed with mozilla .. when download links start showing
up as plain text instead of downloading .. could someone update here if they're
working on a fix for this please.

Revision history for this message
In , Jruderman (jruderman) wrote :

See also bug 108313, Mozilla should display text/foo (where foo is unknown) as
text by default instead of trying to download it.

Revision history for this message
In , Jruderman (jruderman) wrote :

*** Bug 163670 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Jo-hermans (jo-hermans) wrote :

*** Bug 108313 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Martin Schröder (martin-oneiros) wrote :

*** Bug 166329 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Jonasj-qio (jonasj-qio) wrote :

*** Bug 166354 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Jonasj-qio (jonasj-qio) wrote :

Related/dupe: Bug 57342, Add "View as Text" option for unknown mime content-type.

Revision history for this message
In , Jonasj-qio (jonasj-qio) wrote :

Related: Bug 11521, View as different media type support.

Revision history for this message
In , Relf (relf) wrote :

*** This bug has been marked as a duplicate of 11521 ***

Revision history for this message
In , Relf (relf) wrote :

*** Bug 57342 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Bzbarsky (bzbarsky) wrote :

Reopening, since this, unlike bug 11521, may actually be fixable in a reasonable
manner...

Revision history for this message
In , Relf (relf) wrote :

Hmmm...
Boris, what's about bug 156788 ? Let's reopen it also...

Revision history for this message
In , Bzbarsky (bzbarsky) wrote :

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.

Revision history for this message
In , Bzbarsky (bzbarsky) wrote :

*** Bug 197579 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Rggammon (rggammon) wrote :

I'm trying to address this bug through a mozdev.org project based around a
nsIHttpNotify component.

I'm trying to change the content type in nsIHttpNotify::OnExamineResponse via a
call to nsHttpChannel::SetResponseHeader("Content-Type", ...)

This is explicity blocked in nsHttpChannel.cpp:2734 (returns NS_ERROR_ILLEGAL_VALUE)

Any chance of getting a patch accepted that would change this behavior?

Revision history for this message
In , Bzbarsky (bzbarsky) wrote :

Why not just call SetContentType instead?

Revision history for this message
In , Rggammon (rggammon) wrote :

Oops. I've got it working now -- if I change from text/html to text/plain, I get
html source in my browser window, as expected. Thanks!

Revision history for this message
In , Rggammon (rggammon) wrote :

I have a project at http://forcecontenttype.mozdev.org that would address the
original fellow's issue.

Revision history for this message
In , Matti-mversen (matti-mversen) wrote :

*** Bug 213316 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Bzbarsky (bzbarsky) wrote :

*** Bug 214313 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Bugzilla-accessibleinter (bugzilla-accessibleinter) wrote :

*** Bug 215706 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Ed-membled (ed-membled) wrote :

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.

Revision history for this message
In , Bzbarsky (bzbarsky) wrote :

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).

Revision history for this message
In , Kalin (kalin) wrote :

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...

Revision history for this message
In , Bugzilla2008 (bugzilla2008) wrote :

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.

Revision history for this message
In , Ed-membled (ed-membled) wrote :

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.

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

-> me. I have a proof-of-concept.

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

Created an attachment (id=130378)
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

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

y'know, this bug's summary sucks, I was unable to find it.

anyway, my work in bug 57342 adds the required backend stuff, and will probably
add the ui too. taking.

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

Created an attachment (id=130410)
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.

Revision history for this message
In , Bzbarsky (bzbarsky) wrote :

> 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.

Revision history for this message
In , Alex-mozillazine (alex-mozillazine) wrote :

> 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. :-)

Revision history for this message
In , Bugzilla-accessibleinter (bugzilla-accessibleinter) wrote :

*** Bug 221998 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

note to self, mReceivedDispositionInfo seems to be sufficient for
mSuspended=TRUE, so the latter variable can maybe be eliminated

Revision history for this message
In , Bzbarsky (bzbarsky) wrote :

*** Bug 226595 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Bzbarsky (bzbarsky) wrote :

*** Bug 227731 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

actually... I will not fix a) from comment 0, at least not anytime soon, so back
to default owner; I'll do b) in bug 57342.

Revision history for this message
In , Mats Palmgren (matspal) wrote :

*** Bug 230252 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Bijumaillist (bijumaillist) wrote :

Bug# 207154 is a duplicate of this bug
I am looking to get context menu like attachment 125014

Revision history for this message
In , Bzbarsky (bzbarsky) wrote :

*** Bug 232751 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Bzbarsky (bzbarsky) wrote :

*** Bug 234108 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Felix Miata (mrmazda) wrote :

*** Bug 236237 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Bzbarsky (bzbarsky) wrote :

*** Bug 236623 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Vdvo (vdvo) wrote :

Were there any big problems with the patch? Biesi, will you be working on it?
Thanks.

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

(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

Revision history for this message
In , David Nesting (dnesting) wrote :

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.

Revision history for this message
In , Asa (asa) wrote :

*** Bug 210384 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

*** Bug 242124 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Jflack (jflack) wrote :

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.

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

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.

Revision history for this message
In , Jsfbbz (jsfbbz) wrote :

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.)

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

> 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.

Revision history for this message
In , Jflack (jflack) wrote :

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?

Revision history for this message
In , Kalin (kalin) wrote :

After almost 4 years discussing, shouldn't this bug be fixed somehow?
:-(

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

yes.

Revision history for this message
In , David Nesting (dnesting) wrote :

(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.

Revision history for this message
In , Jps (jps) wrote :

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.

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

*** Bug 246438 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Work (work) wrote :

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.

Revision history for this message
In , Creidieki+mozbugs (creidieki+mozbugs) wrote :

I believe this is a duplicate of bug 121498.

Revision history for this message
In , Mcow (mcow) wrote :

(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?

Revision history for this message
In , Work (work) wrote :

After some offline discussion it was determined that the problem is with txt
files with 00 in them (I'll attach one for you).

Revision history for this message
In , Work (work) wrote :

Created an attachment (id=151357)
Text File with 00 chars

Revision history for this message
In , Kalin (kalin) wrote :

(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?

Revision history for this message
In , Work (work) wrote :

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.

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

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.

Revision history for this message
In , Ted Mielczarek (ted-mielczarek) wrote :

*** Bug 248893 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Era+mozilla (era+mozilla) wrote :

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.

Revision history for this message
In , Rebel (rebel-old) wrote :

Can't finally someone take a look at this? I can't understand why such
simple thing can't be done for 4 (!) years ...

Revision history for this message
In , James Ross (twpol) wrote :

(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

Revision history for this message
In , Rebel (rebel-old) wrote :

Sorry, I didn't mean any offense. I still hope this annoying bug is finally
going to be fixed one day.

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

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.

Revision history for this message
In , Rebel (rebel-old) wrote :

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 ...]

Revision history for this message
In , Era+mozilla (era+mozilla) wrote :

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.

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

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...

Revision history for this message
In , Ian-hixie (ian-hixie) wrote :

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?

Revision history for this message
In , Ajo+bugzilla (ajo+bugzilla) wrote :

(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.

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

(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/

Revision history for this message
In , Jflack (jflack) wrote :

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.

Revision history for this message
In , Ian-hixie (ian-hixie) wrote :

>> 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.

Revision history for this message
In , Ginn-chen (ginn-chen) wrote :

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.

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

(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.

Revision history for this message
In , Jflack (jflack) wrote :

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....

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

solution: never offer this option when we decided not to apply encodings. that
allows us to easily do this.

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

Created an attachment (id=165149)
backend patch

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

(From update of attachment 165149)
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...

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

Created an attachment (id=165152)
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.

Revision history for this message
In , Bzbarsky (bzbarsky) wrote :

I'll try to get to this in the next few days...

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

(From update of attachment 165149)
forgot to change the uuid...

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

Created an attachment (id=165908)
backend patch v2

Revision history for this message
In , Matti-mversen (matti-mversen) wrote :

*** Bug 272088 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Bzbarsky (bzbarsky) wrote :
Download full text (5.0 KiB)

(From update of attachment 165908)
>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?...

Read more...

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :
Download full text (5.7 KiB)

(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? ...

Read more...

Revision history for this message
In , Bzbarsky (bzbarsky) wrote :

(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.

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

(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?

Revision history for this message
In , Bzbarsky (bzbarsky) wrote :

> (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...

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

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.

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

Created an attachment (id=176645)
backend patch, v3

Revision history for this message
In , Bzbarsky (bzbarsky) wrote :

(From update of attachment 176645)
>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.

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

Created an attachment (id=176937)
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;
 }

Revision history for this message
In , Darin-moz (darin-moz) wrote :
Download full text (3.2 KiB)

(From update of attachment 176937)
>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 do...

Read more...

Revision history for this message
In , Matti-mversen (matti-mversen) wrote :

*** Bug 291120 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Me-at-work (me-at-work) wrote :

(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.

Revision history for this message
In , Olecom (olecom) wrote :

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>

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

that UI seems a bit complex...

Revision history for this message
In , Me-at-work (me-at-work) wrote :

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

Revision history for this message
In , Bugzilla-eddeye (bugzilla-eddeye) wrote :

The extension at http://forcecontenttype.mozdev.org/ looks perfect, at least
until this behavior is implemented in the main codebase. Unfortunately it won't
install in Firefox (1.0.2+). This bug has been open for 6 years. We should be
mortified.

Revision history for this message
In , Bzbarsky (bzbarsky) wrote :

Edward, who is this "we"? Some people have been working on the back-end changes
needed to fix this correctly. If you think you can do a better job, feel free
to fix the bug -- notice the "helpwanted" keyword.

Revision history for this message
In , Bugzilla-eddeye (bugzilla-eddeye) wrote :

(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?

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

> 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.

Revision history for this message
In , Bugzilla-eddeye (bugzilla-eddeye) wrote :

(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?

Revision history for this message
In , Bugzilla-eddeye (bugzilla-eddeye) wrote :

(In reply to comment #27)
> Edward, who is this "we"? Some people have been working on the back-end changes
> needed to fix this correctly. If you think you can do a better job, feel free
> to fix the bug -- notice the "helpwanted" keyword.

Sorry if my info is out of date. From this bug report, the only signs of
activity in 5 years are vague mentions of internals and one extension 2 years
ago. If something's being done, there's no indication here. What is the
current state of affairs?

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

> From a user's perspective, what will this patch accomplish?

nothing. someone will also have to write UI code.

Revision history for this message
In , Bugzilla-eddeye (bugzilla-eddeye) wrote :

(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.

Revision history for this message
In , Olecom (olecom) wrote :

(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.

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

can that discussion be moved elsewhere, please...

Revision history for this message
In , Olecom (olecom) wrote :

(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>

Revision history for this message
In , Dopefishjustin (dopefishjustin) wrote :

The forcecontenttype UI is really overkill for this, something like bug 57342
comment #143 sounds perfect - a View->Show As or View->MIME Type menu item next
to Character Encoding.

Revision history for this message
In , Joao-batista (joao-batista) wrote :

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. :-)

Revision history for this message
In , Jo-hermans (jo-hermans) wrote :

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).

Revision history for this message
In , Jflack (jflack) wrote :

(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

Revision history for this message
In , Joao-batista (joao-batista) wrote :

(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<--------------

Revision history for this message
In , Jflack (jflack) wrote :

(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).

Revision history for this message
In , Joao-batista (joao-batista) wrote :

(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.

Revision history for this message
In , Stewart (smjg) wrote :

(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?

Revision history for this message
In , Benoit-gawab (benoit-gawab) wrote :

I agree. I think we should start with the basic menu, without "Other...", and go
from there.

Revision history for this message
In , Anlan (anlan) wrote :

*** Bug 308632 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Windwalker (windwalker) wrote :

Recently I was trying to view DTD file in Firefox 1.0.7 - with no luck at all.
It was either providing option to save file on local disk, or open it with
default external application.
Unfortunately, I would like to view it as XML - convenient but not available.
So there is my .50 cents. (And a vote too)

Revision history for this message
In , Jruderman (jruderman) wrote :

*** Bug 313296 has been marked as a duplicate of this bug. ***

Revision history for this message
In , James-noble (james-noble) wrote :

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?

Revision history for this message
In , Ian-ianmacfarlane (ian-ianmacfarlane) wrote :

Why don't we just implement "View as text" first, then worry about other formats later?

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

(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.

Revision history for this message
Martin Flack (martin-martinflack) wrote :

A suggestion:

When you click certain files, like .py or .pl files, for example, Firefox brings
up a dialog that offers you the ability to:
1. Open with a certain application
2. Save to disk
What would be nice is a third option:
3. Treat as text/plain

The wording could be altered... "Display as text in browser" or something.

Sometimes you just want to quickly visit a file on the web and look for
something in it, and the fact that you *could* open it in a more customized
application is true but not really easier for you at that moment. If you just
want to look a Python script for a version number at the top it is not necessary
to open it in your IDE or save it to disk; you just want to open it in the
normal viewing window as plain text and quickly find what you need to look at.

Revision history for this message
In , Christian Biesinger (cbiesinger) wrote :

*** Bug 319974 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Peter Clay (pete-flatline) wrote :

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?

Revision history for this message
Rocco Stanzione (trappist) wrote :

Yeah I'm annoyed when I have to save or open a perl script in another app. I don't see a corresponding bug on bugzilla.mozilla.org but it could be the needle in the haystack.

Revision history for this message
Kris Nuttycombe (kris-nuttycombe) wrote :

This is something that has annoyed me for a long time as well. 90% of the time, I have no desire to open the file in a custom editor; I just want to look at the code and go. This applies not just to perl or python files, either - today I ran into it when Firefox wanted to open Emacs (horrors) to view a latex document.

Revision history for this message
In , Jruderman (jruderman) wrote :

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.

Revision history for this message
In , Vincent+moz (vincent+moz) wrote :

(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.

Revision history for this message
In , Jruderman (jruderman) wrote :

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".

Revision history for this message
In , Vincent+moz (vincent+moz) wrote :

(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.

Revision history for this message
In , Timwi (timwi) wrote :

> 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.

Revision history for this message
In , Sylvain Pasche (sylvain-pasche) wrote :

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/

Revision history for this message
In , Matthieu Moy (matthieu-moy) wrote :

The extension is great. Just what I was looking for !!

Thanks !

Revision history for this message
In , Lagrave+bugs+mozilla-org (lagrave+bugs+mozilla-org) wrote :

Great extension. Do you think you could add application/pdf to its known MIME-types?

Revision history for this message
In , Sylvain Pasche (sylvain-pasche) wrote :

(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

Ian Jackson (ijackson)
Changed in firefox:
assignee: ijackson → nobody
Revision history for this message
In , rduke15 (rduke15) wrote :

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!

Revision history for this message
In , Vincent+moz (vincent+moz) wrote :

(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?

Revision history for this message
In , Eyalroz (eyalroz) wrote :

(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.

Revision history for this message
In , Benoit-gawab (benoit-gawab) wrote :

Did it ever dawn on you that this is a Gecko bug? A lot of other applications benefit from Gecko too, not just Firefox.

Revision history for this message
In , Jo-hermans (jo-hermans) wrote :

*** Bug 360817 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Sylvain Pasche (sylvain-pasche) wrote :

*** Bug 360979 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Sylvain Pasche (sylvain-pasche) wrote :

Created an attachment (id=252899)
Toolkit ui hack for testing

Revision history for this message
In , Sylvain Pasche (sylvain-pasche) wrote :

Created an attachment (id=252900)
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.

Revision history for this message
In , Sylvain Pasche (sylvain-pasche) wrote :

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

Changed in firefox:
assignee: nobody → mozillateam
Revision history for this message
John Vivirito (gnomefreak) wrote :

Whats wrong with right clicking the file and opening it in a new tab? that doesnt work?

Changed in firefox:
status: Unconfirmed → Needs Info
Revision history for this message
Kris Nuttycombe (kris-nuttycombe) wrote : Re: [Bug 25830] Re: Option to display file in browser, treat as text/plain

This does not work for any file type not recognized as text. For example,
Java source code (.java), LaTeX files, (.tex), etc. For a programmer, it's
intensely frustrating to have to take the time to download the source and
open it in a text editor when looking at it in the browser would be
preferable.

Kris

On 2/17/07, John Vivirito <email address hidden> wrote:
>
> Whats wrong with right clicking the file and opening it in a new tab?
> that doesnt work?
>
> ** Changed in: firefox (Ubuntu)
> Status: Unconfirmed => Needs Info
>
> ** Tags added: mt-needinfo
>
> --
> Option to display file in browser, treat as text/plain
> https://launchpad.net/bugs/25830
>

--
Some days you're the magician, some days you're the apprentice.

Revision history for this message
Alexander Sack (asac) wrote :

so, can we come up with a well defined set of file-extensions/content-types that can viewed in plain text mode?

Revision history for this message
Kris Nuttycombe (kris-nuttycombe) wrote :

I think that this is exactly contrary to the intent of the request - instead
of attempting to pre-define a set of extensions, simply give me an "open as
plain text" option in the right-click dropdown for a link. Basically, trust
the user to know what is text, and allow them to view it as text with as
little hassle as possible. If an unknown filetype is encountered, have "open
as text" as another option in addition to opening with a third-party program
or downloading the file.

Kris

On 2/20/07, Alexander Sack <email address hidden> wrote:
>
> so, can we come up with a well defined set of file-extensions/content-
> types that can viewed in plain text mode?
>
> --
> Option to display file in browser, treat as text/plain
> https://launchpad.net/bugs/25830
>

--
Some days you're the magician, some days you're the apprentice.

Revision history for this message
Martin Flack (martin-martinflack) wrote :

Kris is correct w.r.t. my original intent.

This applies to source code of any kind from any platform; and to a large extent any Unix-style formats that are specially parsed but also happen to be somewhat text readable. But trying to make a list defeats the purpose. Better to always show the option, or make it an expert feature that you can turn on and then it always shows the option.

Basically there are applications bound to extensions/types but in some cases we want to look at the file very briefly rather than work in the default application, and considering that Firefox already has a perfectly good mechanism to display plain text files, it's a shame not to simply give the user a faster route into that mode.

An argument could be made that an array of XML-based formats could be given analogous treatment - i.e. when you click on a KML file instead of running Google Earth you could have an option to "Render as plain XML". But this isn't as needed I think, and in fact the plain text rendering would often be sufficient for that as well. But it's something else to think about. In this case you could offer that option only if the file starts with "<?xml".

David Farning (dfarning)
Changed in firefox:
assignee: mozillateam → mozilla-bugs
Changed in firefox:
assignee: mozilla-bugs → asac
Revision history for this message
era (era) wrote :

For the record, the "Open in Browser" extension does this, and gets it exactly right. Why this cannot be implemented natively in Firefox is beyond me, but a workaround and model implementation exists.

http://www.spasche.net/mozilla/

The canonical related upstream bug is https://bugzilla.mozilla.org/show_bug.cgi?id=57342 and I think there is one in the Debian BTS about this too.

Revision history for this message
Alexander Sack (asac) wrote :

going to in progress, as upstream is more or less on it.

Changed in firefox:
status: Needs Info → In Progress
Changed in firefox:
status: Unknown → In Progress
Alexander Sack (asac)
Changed in firefox:
assignee: asac → mozilla-bugs
Revision history for this message
In , Gavin Sharp (gavin-sharp) wrote :

*** Bug 383037 has been marked as a duplicate of this bug. ***

Revision history for this message
era (era) wrote :

See also bug #39136

Revision history for this message
In , Denis Kasak (denis-kasak) wrote :

Any news on this bug? It's been some time since the last post.

Revision history for this message
In , Robert (robrwo) wrote :

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.

Revision history for this message
In , Bzbarsky (bzbarsky) wrote :

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.

Alexander Sack (asac)
Changed in firefox:
assignee: mozilla-bugs → nobody
status: In Progress → Triaged
Changed in firefox-3.0:
importance: Undecided → Wishlist
status: New → Triaged
Revision history for this message
In , Majuki (majuki) wrote :

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.

Revision history for this message
In , Jduell-mcbugs (jduell-mcbugs) wrote :

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.

Revision history for this message
In , Joekjunction-forums (joekjunction-forums) wrote :

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.

Revision history for this message
In , Ali-ebrahim (ali-ebrahim) wrote :

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...

Revision history for this message
In , Majuki (majuki) wrote :

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.

Revision history for this message
In , Eyalroz (eyalroz) wrote :

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.

Revision history for this message
In , Scientes-bugs+mozilla-6d4590a7b797c005d0b3 (scientes-bugs+mozilla-6d4590a7b797c005d0b3) wrote :

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 pissed 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.

Revision history for this message
In , Joekjunction-forums (joekjunction-forums) wrote :

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.

Revision history for this message
In , Robert (robrwo) wrote :

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."

Revision history for this message
In , Timwi (timwi) wrote :

> 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)

Revision history for this message
In , Joekjunction-forums (joekjunction-forums) wrote :

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.

Revision history for this message
In , Robert (robrwo) wrote :

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.

Revision history for this message
In , Simetrical+ff (simetrical+ff) wrote :

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.)

Revision history for this message
In , Reed Loden (reed) wrote :

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.

Revision history for this message
In , Torisugari (torisugari) wrote :

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.

Revision history for this message
In , Torisugari (torisugari) wrote :

Created an attachment (id=374753)
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.

Revision history for this message
Micah Gersten (micahg) wrote :

There will not be any more fixes for Firefox 2.

Changed in firefox (Ubuntu):
status: Triaged → Won't Fix
Revision history for this message
In , Matti-mversen (matti-mversen) wrote :

*** Bug 501328 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Zug-treno (zug-treno) wrote :

*** Bug 497445 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Bryan-w-taylor (bryan-w-taylor) wrote :

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.

Revision history for this message
In , Jruderman (jruderman) wrote :

I'm curious how the extension avoids the security issues that a naive implementation would have.

Revision history for this message
In , Jruderman (jruderman) wrote :

I filed bug 504441 for the security parts, which will probably want to be a separate patch anyway.

Revision history for this message
In , Sylvain Pasche (sylvain-pasche) wrote :

(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.

Revision history for this message
In , Abwillis1 (abwillis1) wrote :

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.

Revision history for this message
In , Jsfbbz (jsfbbz) wrote :

(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.

Revision history for this message
In , Vincent+moz (vincent+moz) wrote :

(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.

Changed in firefox:
importance: Unknown → Wishlist
Revision history for this message
In , flying sheep (flying-sheep) wrote :

the extension „open in browser“ doesn’t work on local files (offering only „view source“)

the solution should work on those, too.

Revision history for this message
In , Michal Suchanek (hramrach) wrote :

(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.

Revision history for this message
In , Me-shadsterling (me-shadsterling) wrote :

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.

Changed in firefox (Ubuntu):
status: Won't Fix → Triaged
no longer affects: firefox-3.0 (Ubuntu)
Revision history for this message
In , sergiomb (sergio-sergiomb) wrote :

I need "open in browser" working ! , I hope this is not another stupid security reason

Revision history for this message
In , Alexander-stohr-5 (alexander-stohr-5) wrote :

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.

Revision history for this message
In , Alexander-stohr-5 (alexander-stohr-5) wrote :

Created attachment 8338461
screenshot of browser file reception dialog that has a grayed out "remember" item

Revision history for this message
In , Mozilla3 (mozilla3) wrote :

@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.

Revision history for this message
In , Ashundi (ashundi) wrote :

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.

Revision history for this message
In , Stewart (smjg) wrote :

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?

Revision history for this message
In , Vincent-moz (vincent-moz) wrote :

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.

Revision history for this message
In , Francis-uy (francis-uy) wrote :

*** Bug 578990 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Jonathan Watt (jwatt) wrote :

Mass bug change to replace various 'parity' whiteboard flags with the new canonical keywords. (See bug 1443764 comment 13.)

Revision history for this message
In , Michael Lippert (mlippert255) wrote :

Addressing this issue would help a lot of power users. I think all that's needed is the capability to set somewhere (even about:config) that all unknown text/* types should be handled as internally as text/plain.

Currently I have to use Chrome w/ an extension to render a markdown file from my local filesystem. It is loaded w/ the appropriate mime type: text/markdown which according to this stackoverflow (https://stackoverflow.com/questions/10701983/what-is-the-mime-type-for-markdown) was registered as RFC7763 in March of 2016.

There is at least one firefox extension which will render a markdown file. but it never gets that far, firefox only gives the options to download or to specify an external application for the file.

There are other text/* types that it would be really nice if they were just viewable in the browser rendered as text/plain, such as those for source files (text/x-c, text/x-java-source, ...). On my system the mime type is also associated w/ the list of applications I select from in the file manager to open those files, so I want to be able to distinguish them from one another (I want to open markdown files with different applications than js source files or script files for example). I mention this because one workaround suggested was just to tag markdown files as text/plain, but I'd rather continue to use Chrome than lose the ability to distinguish the files in the file manager.

Changed in firefox:
importance: Wishlist → Medium
status: In Progress → Confirmed
Revision history for this message
In , Stewart (smjg) wrote :

(In reply to Michael Lippert from comment #217)
> Addressing this issue would help a lot of power users. I think all that's needed is the capability to set somewhere (even about:config) that all unknown text/* types should be handled as internally as text/plain.

I disagree. It's only natural that sometimes the user will want to save the file to disk, sometimes the user will want to open the file in an external application, and sometimes the user will want to view the file in the browser. Why should we force the user to choose on an all-or-nothing basis, and moreover restrict it to text/* types?

> There are other text/* types that it would be really nice if they were just viewable in the browser rendered as text/plain, such as those for source files (text/x-c, text/x-java-source, ...).

Indeed, Moreover, there are many text-based file formats out there - not just those that have text/* MIME types (e.g. application/xml, and apparently application/javascript and application/json exist as well).

> On my system the mime type is also associated w/ the list of applications I select from in the file manager to open those files, so I want to be able to distinguish them from one another (I want to open markdown files with different applications than js source files or script files for example). I mention this because one workaround suggested was just to tag markdown files as text/plain, but I'd rather continue to use Chrome than lose the ability to distinguish the files in the file manager.

What kind of "system" is this - an operating system, or a website with an associated file manager?

The MIME type is for specifying what kind of file it is, not what the user agent is to do with it. We shouldn't force anybody to misdeclare MIME types in order to work around browser restrictions. We should fix the restrictions.

Revision history for this message
era (era) wrote :

@jwatt What's this about a mass bug change? The link is to an uninformative routine comment on an unrelated bug report, and googling for similar comments only brings up this single bug report. Was this a failed test for an upcoming actual mass bug change? Or can you explain what it means with a correct link, or more information about what the link means?

Revision history for this message
In , Michael Lippert (mlippert255) wrote :

(In reply to Stewart Gordon from [comment #218](https://bugzilla.mozilla.org/show_bug.cgi?id=57342#c218))

I think you completely misunderstood what I was getting at, because your final statement is what I was saying (well attempting to as it obviously wasn't as clear as I hoped).

All I was saying is that if a file is identified with a mime type of `text/*` that it is text, and firefox displays text just fine as it currently does with `text/plain`. So firefox can handle any text file it doesn't explicitly have another process for as `text/plain` to display it **in Firefox**, and that should be an option in addition to _save_, and _specifying an external application_ for handling that file.

I was not requesting that the user choose on an all-or-nothing basis at all, I wanted to add an option that doesn't exist at this time, but should for text/* types because the support is already baked in.

Revision history for this message
In , Kalin (kalin) wrote :

Just a restate for my [comment #57 from 16 years ago](https://bugzilla.mozilla.org/show_bug.cgi?id=57342#c57) with a slight update... it is still valid

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 EUR cent...

Revision history for this message
In , Stewart (smjg) wrote :

(In reply to Michael Lippert from comment #219)
> (In reply to Stewart Gordon from [comment #218](https://bugzilla.mozilla.org/show_bug.cgi?id=57342#c218))
>
> I think you completely misunderstood what I was getting at, because your final statement is what I was saying (well attempting to as it obviously wasn't as clear as I hoped).

That final comment wasn't aimed at you personally. Sorry if it sounded like it was. Really, I was commenting on the suggested workaround you made reference to, rather than on your comment itself.

> All I was saying is that if a file is identified with a mime type of `text/*` that it is text, and firefox displays text just fine as it currently does with `text/plain`. So firefox can handle any text file it doesn't explicitly have another process for as `text/plain` to display it **in Firefox**, and that should be an option in addition to _save_, and _specifying an external application_ for handling that file.
>
> I was not requesting that the user choose on an all-or-nothing basis at all, I wanted to add an option that doesn't exist at this time, but should for text/* types because the support is already baked in.

Which is basically what this bug ticket is asking for all along. I was saying that it shouldn't be restricted to text/* types, because other types may also be text-based formats. Another very good example of this is PGN (which seems to be represented by various application/* types).

Revision history for this message
In , Gijskruitbosch+bugs (gijskruitbosch+bugs) wrote :

Backlog grooming: bugs without an assignee cannot be P1.

Revision history for this message
In , N-mozilla (n-mozilla) wrote :

In December 2000, just shy of 21 years ago, comment number 6:
"Marking as NEW so someone will either mark it as WONTFIX or INVALID."

Status today, 25 Aug 2021 (30th birthday of Linus announcing his OS in Usenet):

"Status: NEW"

And I see multiple patches attached to this ticket from various points over the years. This is so disheartening.

Revision history for this message
In , Z-sam-i (z-sam-i) wrote :

Encountered this bug today trying to get a plaintext format (with the mime type `application/<something>`) to display as plaintext in the browser rather than Open With > Firefox (and opening a new window.)

Is there still no workaround for enabling this type of functionality, even by modifying config files in the profile? I tried messing around with `handlers.json` (the file that holds the mime type preferences set in `about:preferences` under the "Files and Applications" header) but had no luck.

Some content types in `about:preferences` permit users to select "Open in Firefox" while others don't. Where is the safelist of permitted content types for this behavior? Could a simple solution to this bug be to add an `about:config` flag that would allow power users to select "Open in Firefox" for any content type?

Changed in firefox:
importance: Medium → Unknown
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.