From 3df1d271c43202e0f22b6aaec370b0f6a21263cf Mon Sep 17 00:00:00 2001 From: "dveditz%netscape.com" Date: Mon, 24 Jun 2002 07:17:42 +0000 Subject: [PATCH] Don't reveal full plugin pathname (bug 88183) r=peterl, sr=alecf git-svn-id: svn://10.0.0.236/trunk@123919 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/modules/libpref/src/init/all.js | 1 + .../plugin/base/src/nsPluginHostImpl.cpp | 34 +++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/mozilla/modules/libpref/src/init/all.js b/mozilla/modules/libpref/src/init/all.js index bfc9c81bb88..b96aa7c2ddb 100644 --- a/mozilla/modules/libpref/src/init/all.js +++ b/mozilla/modules/libpref/src/init/all.js @@ -736,6 +736,7 @@ pref("browser.downloadmanager.behavior", 0); // if true, allow plug-ins to override internal imglib decoder mime types in full-page mode pref("plugin.override_internal_types", false); +pref("plugin.expose_full_path", false); // if true navigator.plugins reveals full path // See bug 136985. Gives embedders a pref to hook into to show // a popup blocker if they choose. diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp index 624cf675420..296772d5b18 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -4338,11 +4338,39 @@ public: NS_METHOD GetFilename(nsAString& aFilename) { + PRBool bShowPath; + nsCOMPtr prefService = do_GetService(NS_PREF_CONTRACTID); + if (prefService && + NS_SUCCEEDED(prefService->GetBoolPref("plugin.expose_full_path",&bShowPath)) && + bShowPath) + { + // only show the full path if people have set the pref, + // the default should not reveal path information (bug 88183) #ifdef XP_MAC - return DoCharsetConversion(mUnicodeDecoder, mPluginTag.mFullPath, aFilename); -#else - return DoCharsetConversion(mUnicodeDecoder, mPluginTag.mFileName, aFilename); + return DoCharsetConversion(mUnicodeDecoder, mPluginTag.mFullPath, aFilename); +#else + return DoCharsetConversion(mUnicodeDecoder, mPluginTag.mFileName, aFilename); #endif + } + + nsFileSpec spec; + if (mPluginTag.mFullPath) + { +#ifndef XP_MAC + NS_ERROR("Only MAC should be using nsPluginTag::mFullPath!"); +#endif + spec = mPluginTag.mFullPath; + } + else + { + spec = mPluginTag.mFileName; + } + + char* name = spec.GetLeafName(); + nsresult rv = DoCharsetConversion(mUnicodeDecoder, name, aFilename); + if (name) + nsCRT::free(name); + return rv; } NS_METHOD GetName(nsAString& aName)