diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-09 20:43:23 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-09 20:43:23 +0000 |
commit | f30df21db00005994685c62dfffd2936adc5d821 (patch) | |
tree | 20b1f1d9495667e39aee50fd77221467611116a1 /chrome/common | |
parent | ac18a05f2eead7b71b3f06695606c15c410d2a29 (diff) | |
download | chromium_src-f30df21db00005994685c62dfffd2936adc5d821.zip chromium_src-f30df21db00005994685c62dfffd2936adc5d821.tar.gz chromium_src-f30df21db00005994685c62dfffd2936adc5d821.tar.bz2 |
Fixed a bug where themes with non-ASCII image file names would not load.
Fixed the same issue with plugin paths.
BUG=102625
TEST=no
Review URL: http://codereview.chromium.org/8502043
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109293 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/extensions/extension.cc | 2 | ||||
-rw-r--r-- | chrome/common/extensions/extension_file_util.cc | 3 | ||||
-rw-r--r-- | chrome/common/extensions/extension_file_util_unittest.cc | 43 |
3 files changed, 46 insertions, 2 deletions
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc index 70bb789..f898a52 100644 --- a/chrome/common/extensions/extension.cc +++ b/chrome/common/extensions/extension.cc @@ -1797,7 +1797,7 @@ bool Extension::InitFromValue(const DictionaryValue& source, int flags, // displayed across platforms. #if !defined(OS_CHROMEOS) plugins_.push_back(PluginInfo()); - plugins_.back().path = path().AppendASCII(path_str); + plugins_.back().path = path().Append(FilePath::FromUTF8Unsafe(path_str)); plugins_.back().is_public = is_public; #endif } diff --git a/chrome/common/extensions/extension_file_util.cc b/chrome/common/extensions/extension_file_util.cc index 7fe9b5e..33df260 100644 --- a/chrome/common/extensions/extension_file_util.cc +++ b/chrome/common/extensions/extension_file_util.cc @@ -164,7 +164,8 @@ bool ValidateExtension(const Extension* extension, std::string* error) { iter != images_value->end_keys(); ++iter) { std::string val; if (images_value->GetStringWithoutPathExpansion(*iter, &val)) { - FilePath image_path = extension->path().AppendASCII(val); + FilePath image_path = extension->path().Append( + FilePath::FromUTF8Unsafe(val)); if (!file_util::PathExists(image_path)) { *error = l10n_util::GetStringFUTF8(IDS_EXTENSION_INVALID_IMAGE_PATH, diff --git a/chrome/common/extensions/extension_file_util_unittest.cc b/chrome/common/extensions/extension_file_util_unittest.cc index 39df382..0a1f986 100644 --- a/chrome/common/extensions/extension_file_util_unittest.cc +++ b/chrome/common/extensions/extension_file_util_unittest.cc @@ -5,8 +5,10 @@ #include "chrome/common/extensions/extension_file_util.h" #include "base/file_util.h" +#include "base/json/json_value_serializer.h" #include "base/path_service.h" #include "base/scoped_temp_dir.h" +#include "base/stringprintf.h" #include "base/utf_string_conversions.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/extensions/extension.h" @@ -238,6 +240,47 @@ TEST(ExtensionFileUtil, ExtensionURLToRelativeFilePath) { } } +static scoped_refptr<Extension> LoadExtensionManifest( + const std::string& manifest_value, + const FilePath& manifest_dir, + Extension::Location location, + int extra_flags, + std::string* error) { + JSONStringValueSerializer serializer(manifest_value); + scoped_ptr<Value> result(serializer.Deserialize(NULL, error)); + if (!result.get()) + return NULL; + + scoped_refptr<Extension> extension = Extension::Create( + manifest_dir, location, *static_cast<DictionaryValue*>(result.get()), + extra_flags, error); + return extension; +} + +TEST(ExtensionFileUtil, ValidateThemeUTF8) { + ScopedTempDir temp; + ASSERT_TRUE(temp.CreateUniqueTempDir()); + + // "aeo" with accents. Use http://0xcc.net/jsescape/ to decode them. + std::string non_ascii_file = "\xC3\xA0\xC3\xA8\xC3\xB2.png"; + FilePath non_ascii_path = temp.path().Append(FilePath::FromUTF8Unsafe( + non_ascii_file)); + file_util::WriteFile(non_ascii_path, "", 0); + + std::string kManifest = + base::StringPrintf( + "{ \"name\": \"Test\", \"version\": \"1.0\", " + " \"theme\": { \"images\": { \"theme_frame\": \"%s\" } }" + "}", non_ascii_file.c_str()); + std::string error; + scoped_refptr<Extension> extension = LoadExtensionManifest( + kManifest, temp.path(), Extension::LOAD, 0, &error); + ASSERT_TRUE(extension.get()) << error; + + EXPECT_TRUE(extension_file_util::ValidateExtension(extension, &error)) << + error; +} + // TODO(aa): More tests as motivation allows. Maybe steal some from // ExtensionService? Many of them could probably be tested here without the // MessageLoop shenanigans. |