Closed
Bug 789077
Opened 12 years ago
Closed 12 years ago
Since Bug 567077 landed, .xhtml files encoded as UTF-16 Little Endian are not displayed, but instead offered for download as MP3 files.
Categories
(Core :: Audio/Video, defect)
Tracking
()
RESOLVED
FIXED
mozilla18
Tracking | Status | |
---|---|---|
firefox18 | - | --- |
People
(Reporter: xeno42alpha, Assigned: padenot)
References
()
Details
(Keywords: regression)
Attachments
(4 files, 2 obsolete files)
877.96 KB,
image/png
|
Details | |
89.39 KB,
image/png
|
Details | |
2.35 KB,
patch
|
Details | Diff | Splinter Review | |
2.32 KB,
patch
|
Details | Diff | Splinter Review |
Steps to reproduce:
Open a .xhtml file.
Actual results:
The file gets offered for download as a MP3 file.
Expected results:
The .xhtml file is displayed as a webpage.
------------------------------------------------------------
Summary:
After I updated Nightly to 18.0a1 (2012-09-06), I tried to open a local .xhtml file I was working on. Instead getting displayed as a web page, it was offered for download as an MP3 file.
Trying to open http://www.rialgar.de/ got the same result.
------------------------------------------------------------
Additional Information:
Response from Server:
HTTP/1.1 200 OK
Date: Thu, 06 Sep 2012 15:41:30 GMT
Server: Apache
Last-Modified: Sat, 25 Aug 2012 14:33:24 GMT
ETag: "1c7348cb-1a40-4c817f995f500"
Accept-Ranges: bytes
Content-Length: 6720
X-Powered-By: PleskLin
Keep-Alive: timeout=15, max=98
Connection: Keep-Alive
Content-Type: application/xhtml+xml
Reporter | ||
Comment 1•12 years ago
|
||
Reporter | ||
Comment 2•12 years ago
|
||
Updated•12 years ago
|
tracking-firefox18:
--- → ?
Keywords: regression
Assignee | ||
Comment 3•12 years ago
|
||
I can reproduce, but only on certain web pages. Most of them are not affected. I'll investigate right now.
Status: NEW → ASSIGNED
Assignee | ||
Updated•12 years ago
|
Assignee: nobody → paul
Comment 4•12 years ago
|
||
Note that this occurs even when the site sends a mimetype:
$ curl --head http://rialgar.de/
...
Content-Type: application/xhtml+xml
Comment 5•12 years ago
|
||
rialgar.de uses a UTF-16 encoding, starting with the 0xfffe byte-order marker, which looks like it matches your 0xfffa,0xfffb mask pattern. You may need to look for the next header at the expected offset to reliably identify mp3.
Comment 6•12 years ago
|
||
So my idea doesn't work, because draft-ietf-websec-mime-sniff says the sniffer stops after 512 bytes, and an mp3 frame can be longer than that.
I checked 8 different mp3 files with 'iconv --from-code=UTF-16 --to-code=UTF-8 file.mp3 > /dev/null' and while all contained an invalid UTF-16 sequence, for several files it with more than 512 bytes in, so that doesn't work either.
Looks like mp3 sniffing will require some format research.
Assignee | ||
Comment 7•12 years ago
|
||
This patch removes the pattern for an mp3 file without ID3 tag, so we don't
break the web. Bug 789123 has been filed to add a decent mechanism to sniff for
and mp3 file without ID3 tags.
This patch also removes the test. It does not remove the file, since I have good
hope to be able to re-enable the test in the near future.
Attachment #658927 -
Flags: review?(cpearce)
Comment 8•12 years ago
|
||
But why are we sniffing at all if the server sent "Content-Type: application/xhtml+xml"?
Assignee | ||
Comment 9•12 years ago
|
||
bz, as far as my research went, [1] allows the overriding of the doctype using sniffers. I _guess_ this is the code path that is used when loading a page.
[1]: http://mxr.mozilla.org/mozilla-central/source/docshell/base/nsDocShell.cpp#9430
Comment 10•12 years ago
|
||
Yes, but the media sniffer is not supposed to do overriding, I would think. It _can_ given how it hooks in, but it _shouldn't_.
Assignee | ||
Comment 11•12 years ago
|
||
Here is a patch. As discussed on IRC, we return early if the type is not empty,
or if it is not application/octet-stream.
Attachment #658962 -
Flags: review?(bzbarsky)
Comment 12•12 years ago
|
||
Comment on attachment 658962 [details] [diff] [review]
Sniff for a media only if the Content-Type is unknown, or octet-stream. r=
As written, this will return if the type is nonempty. As in, it'll break octet-stream sniffing (which I hope we have tests for!)
I think you want something more like this:
if (!contentType.IsEmpty() &&
!contentType.EqualsLiteral(APPLICATION_OCTET_STREAM) &&
!contentType.EqualsLiteral(UNKNOWN_CONTENT_TYPE)) {
return NS_ERROR_NOT_AVAILABLE;
}
r=me with that.
Attachment #658962 -
Flags: review?(bzbarsky) → review+
Comment 13•12 years ago
|
||
Comment on attachment 658927 [details] [diff] [review]
Remove sniffing for mp3 without ID3, because of false positive. r=
Review of attachment 658927 [details] [diff] [review]:
-----------------------------------------------------------------
Good. Can you make Boris's changes, upload the patch, and push to Try? Let's get this landed ASAP.
Attachment #658927 -
Flags: review?(cpearce) → review+
Reporter | ||
Comment 14•12 years ago
|
||
I ran some test with local files, results as following:
– UTF-8 without Byte Order Mark: works
– UTF-8 with Byte Order Mark: works
– UTF-16 Big Endian: works
– UTF-16 Little Endian: fails
Assignee | ||
Comment 15•12 years ago
|
||
Both patches (with bz's comment addressed) pushed to try: https://tbpl.mozilla.org/?tree=Try&rev=ac22cdf7b347
Comment 16•12 years ago
|
||
(In reply to xeno42alpha from comment #14)
> I ran some test with local files, results as following:
> – UTF-8 without Byte Order Mark: works
> – UTF-8 with Byte Order Mark: works
> – UTF-16 Big Endian: works
> – UTF-16 Little Endian: fails
Thanks for testing, that matches my results as well.
Reporter | ||
Updated•12 years ago
|
Summary: Since Bug 567077 landed, .xhtml files are not displayed, but instead offered for download as MP3 files. → Since Bug 567077 landed, .xhtml files encoded as UTF-16 Little Endian are not displayed, but instead offered for download as MP3 files.
Comment 17•12 years ago
|
||
I have never seen a MP3 file with FFFE, it's always FFFA or more commonly FFFB. The only completely safe way to detect MP3 would be to find the first frame using the frame sync, read the header and compute the frame length and then search for the next frame at the specific offset, if it's there, it's MP3, if not, it isn't.
Reporter | ||
Updated•12 years ago
|
Assignee | ||
Comment 18•12 years ago
|
||
We investigated doing something like comment 17 describes, but unfortunately, the spec requires us to read at most 512 bytes, and we thought that an mp3 frame could be longer than that. Can someone confirm or infirm that?
We should discuss this in bug 789123, which is about implementing mp3 sniffing properly.
Assignee | ||
Comment 19•12 years ago
|
||
This is green on try: https://tbpl.mozilla.org/?tree=Try&rev=ac22cdf7b347
Assignee | ||
Updated•12 years ago
|
Attachment #658927 -
Attachment is obsolete: true
Assignee | ||
Comment 20•12 years ago
|
||
Updated commit message.
Assignee | ||
Updated•12 years ago
|
Attachment #658962 -
Attachment is obsolete: true
Assignee | ||
Updated•12 years ago
|
Keywords: checkin-needed
Comment 21•12 years ago
|
||
(In reply to Paul ADENOT (:padenot) from comment #19)
> Created attachment 659392 [details] [diff] [review]
> This is green on try: https://tbpl.mozilla.org/?tree=Try&rev=ac22cdf7b347
Pushing directly to m-c for tomorrow's nightly.
https://hg.mozilla.org/mozilla-central/rev/882b5dcaed46
https://hg.mozilla.org/mozilla-central/rev/530da2e30cef
Should this have tests?
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Flags: in-testsuite?
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → mozilla18
Assignee | ||
Comment 22•12 years ago
|
||
Ryan, this is a bug fix for a feature that already have tests.
On the other hands our test suite did check the behavior we want, i.e. that the media sniffer sniff only when we want it to sniff. I'll see to write a test for that part, I suppose we can do it with an xpcshell test.
Comment 23•12 years ago
|
||
I figure that when things regress, there's a hole in our test coverage :)
Updated•12 years ago
|
Comment 24•12 years ago
|
||
Tracking bug 567077 in case there are more regressions we need to have awareness about but not tracking here since this is resolved.
You need to log in
before you can comment on or make changes to this bug.
Description
•