From 8b495ca37dee1dcbd6244f3cbdcf32672eb9597e Mon Sep 17 00:00:00 2001 From: "norris%netscape.com" Date: Fri, 14 Jan 2000 00:03:46 +0000 Subject: [PATCH] Fix 18592 Fix example: XPCom components cannot be used under r=mstoltz git-svn-id: svn://10.0.0.236/trunk@57748 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/caps/src/nsCodebasePrincipal.cpp | 6 +++--- mozilla/xpcom/sample/xpconnect-sample.html | 19 ++++++++----------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/mozilla/caps/src/nsCodebasePrincipal.cpp b/mozilla/caps/src/nsCodebasePrincipal.cpp index 8633fe632b2..51e6c9d6229 100644 --- a/mozilla/caps/src/nsCodebasePrincipal.cpp +++ b/mozilla/caps/src/nsCodebasePrincipal.cpp @@ -101,11 +101,11 @@ nsCodebasePrincipal::CanEnableCapability(const char *capability, return NS_ERROR_FAILURE; PRBool enabled; if (NS_FAILED(prefs->GetBoolPref(pref, &enabled)) || !enabled) { - // Unless subject is executing from file:, return denied + // Deny unless subject is executing from file: or resource: nsXPIDLCString scheme; if (NS_FAILED(mURI->GetScheme(getter_Copies(scheme))) || - PL_strcmp(scheme, "file") != 0 || - PL_strcmp(scheme, "resource") != 0) + (PL_strcmp(scheme, "file") != 0 && + PL_strcmp(scheme, "resource") != 0)) { *result = nsIPrincipal::ENABLE_DENIED; return NS_OK; diff --git a/mozilla/xpcom/sample/xpconnect-sample.html b/mozilla/xpcom/sample/xpconnect-sample.html index 9309c725569..f750ba48a46 100644 --- a/mozilla/xpcom/sample/xpconnect-sample.html +++ b/mozilla/xpcom/sample/xpconnect-sample.html @@ -2,22 +2,16 @@
XPConnect Sample

-Ariel Blackenroth <arielb@netscape.com> +Ariel Blackenroth <arielb@rice.edu>
Michael Ang <mang@subcarrier.org>
-Last modified Aug 4, 1999 +Last modified +

-
-NOTE: The example on this page currently won't work out of the box, because -access to arbitrary XPConnect components through Components -object is disabled for web-page JavaScript. When we get our security -story straightened out, we'll restore most access. For now, you can get around -it by finding 'pref("security.checkxpconnect", true);' in the -preferences file (all.js) and setting it to false. -
-

In the spirit of "worse is better" this somewhat rough guide is being released to the world. It will be expanded upon and improved. @@ -38,6 +32,7 @@ using the Components object, then accesses it through the nsISample interface by calling QueryInterface:

+netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 var sample = Components.classes["component://mozilla/sample/sample-world"].createInstance();
 sample = sample.QueryInterface(Components.interfaces.nsISample);
 
@@ -123,6 +118,7 @@ printed is calculated in C++ code defined in <script> /* to use nsSample.js version, use "mozilla.jssample.1" */ +netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var sample = Components.classes["component://netscape/sample"].createInstance(); sample = sample.QueryInterface(Components.interfaces.nsISample); dump("sample = " + sample + "\n");