summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-16 23:11:26 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-16 23:11:26 +0000
commit560541ea404af23c1e91f0ef83b4ed11022a84c7 (patch)
tree63dd18b24d2b6fac408e167bbd71282b813265c9 /chrome/browser
parentcff79266d87a5a5371dc80279517cf53760262a5 (diff)
downloadchromium_src-560541ea404af23c1e91f0ef83b4ed11022a84c7.zip
chromium_src-560541ea404af23c1e91f0ef83b4ed11022a84c7.tar.gz
chromium_src-560541ea404af23c1e91f0ef83b4ed11022a84c7.tar.bz2
Bug 14202: Support relative paths when installing external extensions through prefs.
First we try the path as absolute path. If the file is not found, we try a relative path: [installation path]\extensions This will make installing extensions easier from pre-installed prefs, since we can drop them into an extensions directory under the program directory. BUG=14202 TEST=Specify relative path when installing extensions through prefs. Best to test this with an installer that supports deploying extensions (blocked on 14201) Review URL: http://codereview.chromium.org/125219 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18554 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/extensions/external_pref_extension_provider.cc26
1 files changed, 25 insertions, 1 deletions
diff --git a/chrome/browser/extensions/external_pref_extension_provider.cc b/chrome/browser/extensions/external_pref_extension_provider.cc
index 5ed1a5e..5d16ba0 100644
--- a/chrome/browser/extensions/external_pref_extension_provider.cc
+++ b/chrome/browser/extensions/external_pref_extension_provider.cc
@@ -4,7 +4,10 @@
#include "chrome/browser/extensions/external_pref_extension_provider.h"
+#include "app/app_paths.h"
#include "base/file_path.h"
+#include "base/file_util.h"
+#include "base/path_service.h"
#include "base/string_util.h"
#include "base/version.h"
@@ -56,10 +59,31 @@ void ExternalPrefExtensionProvider::VisitRegisteredExtension(
continue;
}
+ if (external_crx.find(FilePath::kParentDirectory) != StringPiece::npos) {
+ LOG(WARNING) << "Path traversal not allowed in path: "
+ << external_crx.c_str();
+ continue;
+ }
+
+ // See if it's an absolute path...
+ FilePath path(external_crx);
+ if (!path.IsAbsolute()) {
+ // Try path as relative path from external extension dir.
+ FilePath base_path;
+ PathService::Get(app::DIR_EXTERNAL_EXTENSIONS, &base_path);
+ path = base_path.Append(external_crx);
+ }
+
+ if (!file_util::PathExists(path)) {
+ LOG(WARNING) << "Cannot find extension: " << external_crx.c_str();
+ continue; // Path is neither absolute nor relative. Might be
+ // meta-physical, but we don't support those (yet).
+ }
+
scoped_ptr<Version> version;
version.reset(Version::GetVersionFromString(external_version));
visitor->OnExternalExtensionFound(
- WideToASCII(extension_id), version.get(), FilePath(external_crx));
+ WideToASCII(extension_id), version.get(), path);
}
}