Bug 406541 - Followup - Handle failed URI creation, fix typo. r=bzbarsky
authorJohn Schoenick <jschoenick@mozilla.com>
Fri, 02 Mar 2012 14:13:10 -0800
changeset 88181 b0b135e60d351fbbda6987dff6a410771068b855
parent 88180 e365b768a32ebdaa67a4264602d269ed8cbdd571
child 88182 5a9bd18c627ae6a01f83194345c8785f95b2c664
push id22173
push userbmo@edmorley.co.uk
push dateSat, 03 Mar 2012 13:14:42 +0000
treeherdermozilla-central@ed57abebd328 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs406541
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 406541 - Followup - Handle failed URI creation, fix typo. r=bzbarsky
content/base/public/nsIObjectLoadingContent.idl
content/base/src/nsObjectLoadingContent.cpp
--- a/content/base/public/nsIObjectLoadingContent.idl
+++ b/content/base/public/nsIObjectLoadingContent.idl
@@ -81,17 +81,17 @@ interface nsIObjectLoadingContent : nsIS
   unsigned long getContentTypeForMIMEType(in AUTF8String aMimeType);
 
   /**
   * Gets the base URI to be used for this object. This differs from
   * nsIContent::GetBaseURI in that it takes codebase attributes into
   * account. The MIME type is required as some plugins (java) calculate
   * this differently.
   */
-  nsIURI GetObjectBaseURI(in ACString aMimeType);
+  nsIURI getObjectBaseURI(in ACString aMimeType);
 
   /**
    * Returns the plugin instance if it has already been instantiated. This
    * will never instantiate the plugin and so is safe to call even when
    * content script must not execute.
    */
   [noscript] readonly attribute nsNPAPIPluginInstancePtr pluginInstance;
 
--- a/content/base/src/nsObjectLoadingContent.cpp
+++ b/content/base/src/nsObjectLoadingContent.cpp
@@ -1866,19 +1866,28 @@ nsObjectLoadingContent::GetObjectBaseURI
 
   if (codebase.IsEmpty() && aMimeType.Equals("application/x-java-vm")) {
     // bug 406541
     // Java resolves codebase="" as "/" -- so we replicate that quirk, to ensure
     // we run security checks against the same path.
     codebase.AssignLiteral("/");
   }
 
-  nsContentUtils::NewURIWithDocumentCharset(aURI, codebase,
-                                            thisContent->OwnerDoc(),
-                                            baseURI);
+  if (!codebase.IsEmpty()) {
+    nsresult rv = nsContentUtils::NewURIWithDocumentCharset(aURI, codebase,
+                                                            thisContent->OwnerDoc(),
+                                                            baseURI);
+    if (NS_SUCCEEDED(rv))
+      return rv;
+    NS_WARNING("GetObjectBaseURI: Could not resolve plugin's codebase to a URI, using baseURI instead");
+  }
+
+  // Codebase empty or build URI failed, just use baseURI
+  *aURI = NULL;
+  baseURI.swap(*aURI);
   return NS_OK;
 }
 
 nsObjectFrame*
 nsObjectLoadingContent::GetExistingFrame()
 {
   nsCOMPtr<nsIContent> thisContent = do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
   nsIFrame* frame = thisContent->GetPrimaryFrame();