diff --git a/dom/plugins/base/nsPluginTags.cpp b/dom/plugins/base/nsPluginTags.cpp index cf081a48628..7c06f88ee15 100644 --- a/dom/plugins/base/nsPluginTags.cpp +++ b/dom/plugins/base/nsPluginTags.cpp @@ -132,19 +132,29 @@ void nsPluginTag::InitMime(const char* const* aMimeTypes, } for (uint32_t i = 0; i < aVariantCount; i++) { - if (!aMimeTypes[i] || !nsPluginHost::IsTypeWhitelisted(aMimeTypes[i])) { + if (!aMimeTypes[i]) { + continue; + } + + nsAutoCString mimeType(aMimeTypes[i]); + + // Convert the MIME type, which is case insensitive, to lowercase in order + // to properly handle a mixed-case type. + ToLowerCase(mimeType); + + if (!nsPluginHost::IsTypeWhitelisted(mimeType.get())) { continue; } // Look for certain special plugins. - if (nsPluginHost::IsJavaMIMEType(aMimeTypes[i])) { + if (nsPluginHost::IsJavaMIMEType(mimeType.get())) { mIsJavaPlugin = true; - } else if (strcmp(aMimeTypes[i], "application/x-shockwave-flash") == 0) { + } else if (mimeType.EqualsLiteral("application/x-shockwave-flash")) { mIsFlashPlugin = true; } // Fill in our MIME type array. - mMimeTypes.AppendElement(nsCString(aMimeTypes[i])); + mMimeTypes.AppendElement(mimeType); // Now fill in the MIME descriptions. if (aMimeDescriptions && aMimeDescriptions[i]) { diff --git a/dom/plugins/test/mochitest/mixed_case_mime.sjs b/dom/plugins/test/mochitest/mixed_case_mime.sjs new file mode 100644 index 00000000000..3c29b8289e7 --- /dev/null +++ b/dom/plugins/test/mochitest/mixed_case_mime.sjs @@ -0,0 +1,8 @@ +function handleRequest(request, response) +{ + response.processAsync(); + response.setHeader("Content-Type", "application/x-Second-Test", false); + + response.write("Hello world.\n"); + response.finish(); +} diff --git a/dom/plugins/test/mochitest/mochitest.ini b/dom/plugins/test/mochitest/mochitest.ini index 095bc26e91a..2f3de0d1795 100644 --- a/dom/plugins/test/mochitest/mochitest.ini +++ b/dom/plugins/test/mochitest/mochitest.ini @@ -11,6 +11,7 @@ support-files = loremipsum_file.txt loremipsum_nocache.txt loremipsum_nocache.txt^headers^ + mixed_case_mime.sjs neverending.sjs npruntime_identifiers_subpage.html plugin-stream-referer.sjs @@ -41,6 +42,7 @@ support-files = [test_instance_unparent2.html] [test_instance_unparent3.html] [test_instantiation.html] +[test_mixed_case_mime.html] [test_multipleinstanceobjects.html] [test_newstreamondestroy.html] [test_npn_asynccall.html] diff --git a/dom/plugins/test/mochitest/test_mixed_case_mime.html b/dom/plugins/test/mochitest/test_mixed_case_mime.html new file mode 100644 index 00000000000..cb091a8cbb6 --- /dev/null +++ b/dom/plugins/test/mochitest/test_mixed_case_mime.html @@ -0,0 +1,29 @@ + + + Test mixed case mimetype for plugins + + + + + + +

+ + + + + diff --git a/dom/plugins/test/testplugin/secondplugin/Info.plist b/dom/plugins/test/testplugin/secondplugin/Info.plist index 63ce3d3f944..afa83a63cef 100644 --- a/dom/plugins/test/testplugin/secondplugin/Info.plist +++ b/dom/plugins/test/testplugin/secondplugin/Info.plist @@ -24,7 +24,7 @@ Second plug-in for testing purposes. WebPluginMIMETypes - application/x-second-test + application/x-Second-Test WebPluginExtensions diff --git a/dom/plugins/test/testplugin/secondplugin/nptest.rc b/dom/plugins/test/testplugin/secondplugin/nptest.rc index b10fd5d702f..835906d0cb0 100644 --- a/dom/plugins/test/testplugin/secondplugin/nptest.rc +++ b/dom/plugins/test/testplugin/secondplugin/nptest.rc @@ -29,7 +29,7 @@ BEGIN VALUE "FileOpenName", "Second test type" VALUE "FileVersion", "1.0" VALUE "InternalName", "npsecondtest" - VALUE "MIMEType", "application/x-second-test" + VALUE "MIMEType", "application/x-Second-Test" VALUE "OriginalFilename", "npsecondtest.dll" VALUE "ProductName", "Second Test Plug-in" VALUE "ProductVersion", "1.0" diff --git a/dom/plugins/test/testplugin/secondplugin/nptest_name.cpp b/dom/plugins/test/testplugin/secondplugin/nptest_name.cpp index c5606f131d5..12cc68b6942 100644 --- a/dom/plugins/test/testplugin/secondplugin/nptest_name.cpp +++ b/dom/plugins/test/testplugin/secondplugin/nptest_name.cpp @@ -4,4 +4,4 @@ const char *sPluginName = "Second Test Plug-in"; const char *sPluginDescription = "Second plug-in for testing purposes."; -const char *sMimeDescription = "application/x-second-test:ts2:Second test type"; +const char *sMimeDescription = "application/x-Second-Test:ts2:Second test type"; diff --git a/testing/mochitest/b2g-desktop.json b/testing/mochitest/b2g-desktop.json index 15e449a8db3..65af6db030b 100644 --- a/testing/mochitest/b2g-desktop.json +++ b/testing/mochitest/b2g-desktop.json @@ -619,6 +619,7 @@ "dom/plugins/test/mochitest/test_instance_unparent2.html": "Bug 931116, b2g desktop specific, initial triage", "dom/plugins/test/mochitest/test_instance_unparent3.html": "Bug 931116, b2g desktop specific, initial triage", "dom/plugins/test/mochitest/test_instantiation.html": "Bug 931116, b2g desktop specific, initial triage", + "dom/plugins/test/mochitest/test_mixed_case_mime.html": "Bug 931116, b2g desktop specific", "dom/plugins/test/mochitest/test_multipleinstanceobjects.html": "Bug 931116, b2g desktop specific, initial triage", "dom/plugins/test/mochitest/test_newstreamondestroy.html": "Bug 931116, b2g desktop specific, initial triage", "dom/plugins/test/mochitest/test_npn_asynccall.html": "Bug 931116, b2g desktop specific, initial triage",