Closed Bug 394647 Opened 17 years ago Closed 17 years ago

[FIX]nsBinaryDetector::DetermineContentType is outdated

Categories

(Core :: Networking, defect, P1)

x86
Linux
defect

Tracking

()

RESOLVED FIXED
mozilla1.9beta2

People

(Reporter: mpgritti, Assigned: bzbarsky)

References

Details

(Whiteboard: [has-patch])

Attachments

(1 file)

Comment from the code:

// Make sure to do a case-sensitive exact match comparison here.  Apache
// 1.x just sends text/plain for "unknown", while Apache 2.x sends
// text/plain with a ISO-8859-1 charset.  Debian's Apache version, just to
// be different, sends text/plain with iso-8859-1 charset.  Don't do
// general case-insensitive comparison, since we really want to apply this
// crap as rarely as we can.

I tested it Apache with stock Fedora Core 7, RHEL 4 and Ubuntu Feisty. The header is now "text/plain; charset=UTF-8".

As a result all the unknown (to the Apache server) file types are opened inside firefox rather than downloaded by an external helper.

I'm not sure why we are checking the charset at all there, instead of just the mime type. Maybe someone more familiar with this code can explain it?
The problem is that, say, Japanese text will reliably test as binary.  So if we just check the text/plain thing for any text/plain response anyone not using Western languages loses if they send plaintext files.

We can't even check for UTF-8, because then those non-Western language users still get screwed.  So I don't think this code will be changing.

Please file bugs on the relevant distributions to set their fallback MIME type to something that will get sniffed.  If this was a core Apache change, please file a bug on Apache too.

I suppose we could change the code to check the Server: header and just release note that people shouldn't host their content on Apache if they actually want to send non-Western plaintext files.  But that seems like a much more serious problem than the very few non-text files this is going to bite so far.... and we can keep hoping that Apache will fix their default type bug.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → INVALID
Actually, it looks like LastDitchSniff only looks for control characters, which I think would not appear in valid UTF-8.  So we might be able to do this.
Status: RESOLVED → REOPENED
Resolution: INVALID → ---
Attached patch Like soSplinter Review
Christian, the test as written does the GETs one after another.  It could also easily do all the asyncOpens in a single loop and then wait for the server to respond to them all.  Let me know whether you have a preference, ok?
Assignee: nobody → bzbarsky
Status: REOPENED → ASSIGNED
Attachment #286496 - Flags: superreview?(cbiesinger)
Attachment #286496 - Flags: review?(cbiesinger)
Flags: blocking1.9?
Priority: -- → P1
Summary: nsBinaryDetector::DetermineContentType is outdated → [FIX]nsBinaryDetector::DetermineContentType is outdated
Target Milestone: --- → mozilla1.9 M10
Flags: blocking1.9? → blocking1.9+
Whiteboard: [has-patch]
Biesi - ping - we'd like this for B2 which is coming up soon..
Comment on attachment 286496 [details] [diff] [review]
Like so

I don't have a preference for GET-in-a-loop vs all-at-once, use whatever is simpler :)
Attachment #286496 - Flags: superreview?(cbiesinger)
Attachment #286496 - Flags: superreview+
Attachment #286496 - Flags: review?(cbiesinger)
Attachment #286496 - Flags: review+
Fixed.
Status: ASSIGNED → RESOLVED
Closed: 17 years ago17 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Is this a full dupe of bug 261263, or only a subset of it?
It has nothing at all to do with bug 261263, basically.
Well, I guess as that bug is initially filed this one sorta solves a similar problem, in some cases.
This test made tinderbox time out... I disabled it for now, until robcee ups the timeout value a bit.  :(
Flags: in-testsuite+ → in-testsuite?
So even with the bigger timeout value this is failing.  I'm getting back an HTTP channel whose status is either NS_ERROR_ABORT or NS_ERROR_FAILURE.  Hard to tell from the actual output... :(

I have no idea why this is happening.  I'll try to hunt down a windows setup I can test in.
Depends on: 417301
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: