Closed Bug 206659 Opened 21 years ago Closed 11 years ago

Plugin not found, because MIME type has upper-case letters

Categories

(Core Graveyard :: Plug-ins, defect, P5)

Tracking

(Not tracked)

RESOLVED FIXED
mozilla28

People

(Reporter: ljazgar, Assigned: poiru)

References

Details

(Whiteboard: [mentor=gfritzsche][lang=c++][good next bug])

Attachments

(1 file, 3 obsolete files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; pl-PL; rv:1.3.1) Gecko/20030425
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl-PL; rv:1.3.1) Gecko/20030425

If plugin is registered with MIME type, which have uppercase letter, window to
making choice between saving file and running application is shown instead of
launching plugin. 
This happens only if we directly go to resource on server and this resource has
type which should be handled by this plugin.

Reproducible: Always

Steps to Reproduce:
1. Install any plugin with MIME type with upper-case letters inside, e.g.
application/x-Mrowkojad.
2. Refer to resource which has unrecognizable extension for this plugin and
which has MIME type "application/x-Mrowkojad" 
3.

Actual Results:  
Window with information, that type of file is "application/x-mrowkojad"
(lowercase) and proposition of saving file or running application is shown.

Expected Results:  
Plugin should be used.
Comparing Mime types should not be case-sensitive in this case

This happens only if we directly go to resource on server and this resource has
type which should be handled by this plugin.
If resource is loaded by <embed> tag, it works correct. Similarly if resource
has extension handled by this plugin.
I have 2 plugins which make such problems. If you request, I can send you one of
these plugins and jsp page generating data for this plugin.
Status: UNCONFIRMED → NEW
Ever confirmed: true
I just tried this with my debug Win32 build on a fresh trunk pull and it WFM.

Here's steps to repro on Linux (mdk9.1) /w Apache:
1. su - 
2. gedit /etc/httpd/apache-mime.types &
3. Change the case of application/x-shockwave-flash
4. Save, then: service httpd restart
5. Put a test.swf to test with in /var/www/html
6. Validate your server sends the content-type header with mixed case by doing a:
wget http://localhost/test.swf

In mozilla, you can with with a -console switch and NSPR_LOG_MODULES=nsHTTP:8 to
see the HTTP headers. Be sure you clear you cache before testing so that you'll
get a HTTP 200 response (instead of the HTTP 304 Not Modified).

Reporter: please validate this bug happens in a daily trunk build. Thanks!
Um.. This bug is about plugins that report a type with an uppercase letter to
Mozilla (see step 1 in comment 0)
Exactly.
It doesn't matter is server response content-type upper or lower case. 
QA Contact: bmartin → plugins
(In reply to comment #2)
This is also a problem on Linux.
To solve the problem on the client:
sudo vi /etc/mime-types
add JPG to mime type.
Restart Thunderbird and attachement opens.

This is silly. What if I have jpG or jPg ...
A simple tolower() in the comparison will fix this?
Blocks: 59619
Per the description this would be relatively easy to fix by converting the mimetype to lowercase when the plugin tag stores it in nsPluginTag::InitMime() [1].

To test this we could just introduce upper-case to the mimetype entries for the second test plugin [2], "application/x-second-test".

[1] http://hg.mozilla.org/mozilla-central/diff/c4f9959cc9ac/dom/plugins/base/nsPluginTags.cpp
[2] http://mxr.mozilla.org/mozilla-central/source/dom/plugins/test/testplugin/secondplugin/
Priority: -- → P5
Whiteboard: [mentor=gfritzsche][lang=c++][good next bug]
Hi gfritzsche,

I'm interested in working on this bug. Are you available for mentoring?
Hi Srinath, that's great.
Yes, i'm available - feel free to contact me directly via mail or IRC if needed.
A good first step here should be to confirm the issue by:
* first confirming that the following test works fine: dom/plugins/test/mochitest/test_secondPlugin.html
* change the mimetype at [1] to mixed-case, say x-Second-Test
* build dom/plugins
* run the test again - it should now fail

[1] http://hg.mozilla.org/mozilla-central/annotate/5a49762ee832/dom/plugins/test/testplugin/secondplugin/nptest_name.cpp#l7
Assignee: peterlubczynski-bugs → irtmail-bugzilla
Attached patch Test mixed-case mime behavior. (obsolete) — Splinter Review
Srinath found that the test-scenario i described actually wasn't the right one, so here is a patch containing a proper test.

After applying the patch, run the test using:
./mach mochitest-plain dom/plugins/test/mochitest/test_mixed_case_mime.html
Went ahead and took this since Srinath does not seem to be working on it any longer.

Pushed to try: https://tbpl.mozilla.org/?tree=Try&rev=fa7f6595e476
Assignee: irtmail-bugzilla → birunthan
Attachment #816244 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #8333959 - Flags: review?(georg.fritzsche)
Another push to try to test on OS X and Windows: https://tbpl.mozilla.org/?tree=Try&rev=a5204c63c845
OS: Windows XP → All
Hardware: x86 → All
Comment on attachment 8333959 [details] [diff] [review]
Disregard case of MIME types in nsPluginTag::InitMime

Review of attachment 8333959 [details] [diff] [review]:
-----------------------------------------------------------------

This looks good to me and try runs are green - thanks!
Passing on review to Benjamin though as i'm no peer (and shouldn't review my own test-code either).
Attachment #8333959 - Flags: review?(georg.fritzsche)
Attachment #8333959 - Flags: review?(benjamin)
Attachment #8333959 - Flags: review?
Attachment #8333959 - Flags: feedback+
Comment on attachment 8333959 [details] [diff] [review]
Disregard case of MIME types in nsPluginTag::InitMime

Review of attachment 8333959 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/plugins/base/nsPluginTags.cpp
@@ +133,5 @@
> +    if (!aMimeTypes[i]) {
> +      continue;
> +    }
> +
> +    nsCString mimeType(aMimeTypes[i]);

Minor note: per [1], this looks like a good use-case for nsAutoCString.

[1] https://developer.mozilla.org/de/docs/Mozilla_internal_string_guide#The_Concrete_Classes_-_which_classes_to_use_when
(In reply to Georg Fritzsche [:gfritzsche] from comment #14)
> Minor note: per [1], this looks like a good use-case for nsAutoCString.

Fixed, thank you.
Attachment #8333959 - Attachment is obsolete: true
Attachment #8333959 - Flags: review?(benjamin)
Attachment #8334685 - Flags: review?(benjamin)
Why are we taking this patch instead of just asking people to fix their plugins? What real-life plugin does this affect?
(In reply to Benjamin Smedberg  [:bsmedberg] from comment #16)
> Why are we taking this patch instead of just asking people to fix their
> plugins? What real-life plugin does this affect?

Without collecting data i'm not sure if there is a live plugin that this affects. However, unless i'm mixing up what applies here, we should be case-insensitive anyway. Identical text is found in e.g. [1] & [2]:
"The type, subtype, and parameter names are not case sensitive. For example, TEXT, Text, and TeXt are all equivalent top-level media types."

[1] http://tools.ietf.org/html/rfc2045#page-13
[2] http://www.w3.org/Protocols/rfc1341/4_Content-Type.html
Comment on attachment 8334685 [details] [diff] [review]
Disregard case of MIME types in nsPluginTag::InitMime

ok
Attachment #8334685 - Flags: review?(benjamin) → review+
Keywords: checkin-needed
Backed out for B2G desktop mochitest orange. Probably just needs to be skipped on B2G, but please test that on Try first.
https://hg.mozilla.org/integration/mozilla-inbound/rev/2e586efc6160

https://tbpl.mozilla.org/php/getParsedLog.php?id=31465057&tree=Mozilla-Inbound
That definitely shouldn't run on any B2G test-suite. I'm confused though - why is this test run and apparently not the other tests in dom/plugins/test/mochitest/mochitest.ini (those would fail too)?
So, turns out that we need to exclude the tests specifically for b2g-desktop around here:
http://hg.mozilla.org/mozilla-central/annotate/118234ab24ed/testing/mochitest/b2g-desktop.json#l594

Let's do that and a full try run, then this should be good to go.
(In reply to Georg Fritzsche [:gfritzsche] from comment #22)
> So, turns out that we need to exclude the tests specifically for b2g-desktop
> around here:
> http://hg.mozilla.org/mozilla-central/annotate/118234ab24ed/testing/
> mochitest/b2g-desktop.json#l594
> 
> Let's do that and a full try run, then this should be good to go.

Done: https://tbpl.mozilla.org/?tree=Try&rev=1632ba075c8e
Attachment #8334685 - Attachment is obsolete: true
Attachment #8343731 - Flags: review+
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/11e0720cbd28
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla28
Depends on: 985859
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: