aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2006-03-05 22:48:18 +0800
committerChristian Persch <chpe@src.gnome.org>2006-03-05 22:48:18 +0800
commitdee7e0105749445ef85a35fbbff4663ab5869f80 (patch)
tree21ca81856eaba3705dba315f5497afd1defae63a
parent3a2bda9152fbe270dc271fe0992db7b206ed27cc (diff)
downloadgsoc2013-epiphany-dee7e0105749445ef85a35fbbff4663ab5869f80.tar
gsoc2013-epiphany-dee7e0105749445ef85a35fbbff4663ab5869f80.tar.gz
gsoc2013-epiphany-dee7e0105749445ef85a35fbbff4663ab5869f80.tar.bz2
gsoc2013-epiphany-dee7e0105749445ef85a35fbbff4663ab5869f80.tar.lz
gsoc2013-epiphany-dee7e0105749445ef85a35fbbff4663ab5869f80.tar.xz
gsoc2013-epiphany-dee7e0105749445ef85a35fbbff4663ab5869f80.tar.zst
gsoc2013-epiphany-dee7e0105749445ef85a35fbbff4663ab5869f80.zip
Mark application/x-xpinstall as unsafe.
2006-03-05 Christian Persch <chpe@cvs.gnome.org> * data/mime-types-permissions.xml: Mark application/x-xpinstall as unsafe. * embed/mozilla/MozRegisterComponents.cpp: Unregister xpinstall content handler and JS objects; fixes download of .xpi files.
-rw-r--r--ChangeLog11
-rwxr-xr-xdata/mime-types-permissions.xml1
-rw-r--r--embed/mozilla/MozRegisterComponents.cpp85
3 files changed, 67 insertions, 30 deletions
diff --git a/ChangeLog b/ChangeLog
index cfacd7881..5044c048d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2006-03-05 Christian Persch <chpe@cvs.gnome.org>
+ * data/mime-types-permissions.xml:
+
+ Mark application/x-xpinstall as unsafe.
+
+ * embed/mozilla/MozRegisterComponents.cpp:
+
+ Unregister xpinstall content handler and JS objects;
+ fixes download of .xpi files.
+
+2006-03-05 Christian Persch <chpe@cvs.gnome.org>
+
* configure.ac:
* m4/gecko.m4:
diff --git a/data/mime-types-permissions.xml b/data/mime-types-permissions.xml
index 691634df9..b321b24b5 100755
--- a/data/mime-types-permissions.xml
+++ b/data/mime-types-permissions.xml
@@ -434,6 +434,7 @@
<mime-type type="application/x-sharedlib"/>
<mime-type type="application/x-shellscript"/>
<mime-type type="application/x-sms-rom"/>
+<mime-type type="application/x-xpinstall"/>
<mime-type type="inode/blockdevice"/>
<mime-type type="inode/chardevice"/>
<mime-type type="inode/directory"/>
diff --git a/embed/mozilla/MozRegisterComponents.cpp b/embed/mozilla/MozRegisterComponents.cpp
index 03867c699..017623bb9 100644
--- a/embed/mozilla/MozRegisterComponents.cpp
+++ b/embed/mozilla/MozRegisterComponents.cpp
@@ -53,6 +53,8 @@
#include <nsCOMPtr.h>
#include <nsILocalFile.h>
#include <nsNetCID.h>
+#include <nsIScriptNameSpaceManager.h>
+#include <nsCURILoader.h>
#include <glib/gmessages.h>
@@ -76,42 +78,43 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(GtkNSSKeyPairDialogs)
NS_GENERIC_FACTORY_CONSTRUCTOR(GtkNSSSecurityWarningDialogs)
#endif
+#define XPINSTALL_CONTRACTID NS_CONTENT_HANDLER_CONTRACTID_PREFIX "application/x-xpinstall"
/* class information */
NS_DECL_CLASSINFO(EphySidebar)
-static NS_METHOD
-RegisterContentPolicy(nsIComponentManager *aCompMgr, nsIFile *aPath,
- const char *registryLocation, const char *componentType,
- const nsModuleComponentInfo *info)
+static nsresult
+RegisterCategories (void)
{
- nsCOMPtr<nsICategoryManager> cm =
- do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
- NS_ENSURE_TRUE (cm, NS_ERROR_FAILURE);
-
nsresult rv;
- char *oldval = nsnull;
- rv = cm->AddCategoryEntry ("content-policy",
- EPHY_CONTENT_POLICY_CONTRACTID,
- EPHY_CONTENT_POLICY_CONTRACTID,
- PR_TRUE, PR_TRUE, &oldval);
- if (oldval)
- nsMemory::Free (oldval);
- return rv;
-}
+ nsCOMPtr<nsICategoryManager> catMan =
+ do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
+ NS_ENSURE_SUCCESS (rv, rv);
-static NS_METHOD
-RegisterSidebar(nsIComponentManager *aCompMgr, nsIFile *aPath,
- const char *registryLocation, const char *componentType,
- const nsModuleComponentInfo *info)
-{
- nsCOMPtr<nsICategoryManager> cm =
- do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
- NS_ENSURE_TRUE (cm, NS_ERROR_FAILURE);
+ rv = catMan->AddCategoryEntry ("content-policy",
+ EPHY_CONTENT_POLICY_CONTRACTID,
+ EPHY_CONTENT_POLICY_CONTRACTID,
+ PR_FALSE /* don't persist */,
+ PR_TRUE /* replace */,
+ nsnull);
+
+ rv |= catMan->AddCategoryEntry (JAVASCRIPT_GLOBAL_PROPERTY_CATEGORY,
+ "sidebar",
+ NS_SIDEBAR_CONTRACTID,
+ PR_FALSE /* don't persist */,
+ PR_TRUE /* replace */,
+ nsnull);
+
+ /* Unregister the XPI install trigger, so we can just download .xpi files */
+ rv |= catMan->DeleteCategoryEntry (JAVASCRIPT_GLOBAL_PROPERTY_CATEGORY,
+ "InstallVersion",
+ PR_FALSE /* don't persist */);
+ rv |= catMan->DeleteCategoryEntry (JAVASCRIPT_GLOBAL_PROPERTY_CATEGORY,
+ "InstallTrigger",
+ PR_FALSE /* don't persist */);
+ NS_ENSURE_SUCCESS (rv, rv);
- return cm->AddCategoryEntry("JavaScript global property",
- "sidebar", NS_SIDEBAR_CONTRACTID,
- PR_FALSE, PR_TRUE, nsnull);
+ return rv;
}
static const nsModuleComponentInfo sAppComps[] = {
@@ -188,14 +191,13 @@ static const nsModuleComponentInfo sAppComps[] = {
EPHY_CONTENT_POLICY_CID,
EPHY_CONTENT_POLICY_CONTRACTID,
EphyContentPolicyConstructor,
- RegisterContentPolicy
},
{
EPHY_SIDEBAR_CLASSNAME,
EPHY_SIDEBAR_CID,
NS_SIDEBAR_CONTRACTID,
EphySidebarConstructor,
- RegisterSidebar,
+ nsnull /* no register func */,
nsnull /* no unregister func */,
nsnull /* no factory destructor */,
NS_CI_INTERFACE_GETTER_NAME(EphySidebar),
@@ -326,6 +328,29 @@ mozilla_register_components (void)
}
}
+ rv = RegisterCategories();
+ ret = NS_SUCCEEDED (rv);
+
+ /* Unregister xpinstall content handler */
+ nsCID *cidPtr = nsnull;
+ rv = cr->ContractIDToCID (XPINSTALL_CONTRACTID, &cidPtr);
+ if (NS_SUCCEEDED (rv) && cidPtr)
+ {
+ nsCOMPtr<nsIFactory> factory;
+ rv = cm->GetClassObject (*cidPtr, NS_GET_IID (nsIFactory),
+ getter_AddRefs (factory));
+ if (NS_SUCCEEDED (rv))
+ {
+ rv = cr->UnregisterFactory (*cidPtr, factory);
+ }
+
+ nsMemory::Free (cidPtr);
+ }
+ if (NS_FAILED (rv))
+ {
+ g_warning ("Failed to unregister xpinstall content handler!\n");
+ }
+
#if defined(HAVE_MOZILLA_PSM) && !defined(HAVE_GECKO_1_8)
/* Workaround for http://bugzilla.gnome.org/show_bug.cgi?id=164670 */
rv = reregister_secure_browser_ui (cm, cr);