summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorasargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-10 11:47:08 +0000
committerasargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-10 11:47:08 +0000
commit824aed36d5544c2a52e03d3560bbe3ff16ac0c4f (patch)
treeef6549c6029bea82d170bc863ae570d08d382a8d
parent8e09c7af875d86eb8174c5fb5a12ddec9ac8c38e (diff)
downloadchromium_src-824aed36d5544c2a52e03d3560bbe3ff16ac0c4f.zip
chromium_src-824aed36d5544c2a52e03d3560bbe3ff16ac0c4f.tar.gz
chromium_src-824aed36d5544c2a52e03d3560bbe3ff16ac0c4f.tar.bz2
Fix content verifier handling of paths with subdirectories on windows
Any path with a subdirectory was failing on windows because we weren't translating to use windows path separators. BUG=382638 Review URL: https://codereview.chromium.org/321893002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275989 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--extensions/browser/verified_contents.cc3
-rw-r--r--extensions/browser/verified_contents_unittest.cc11
2 files changed, 10 insertions, 4 deletions
diff --git a/extensions/browser/verified_contents.cc b/extensions/browser/verified_contents.cc
index 47bc953..1defc47 100644
--- a/extensions/browser/verified_contents.cc
+++ b/extensions/browser/verified_contents.cc
@@ -185,6 +185,9 @@ bool VerifiedContents::InitFrom(const base::FilePath& path,
return false;
base::FilePath file_path =
base::FilePath::FromUTF8Unsafe(file_path_string);
+#if defined(FILE_PATH_USES_WIN_SEPARATORS)
+ file_path = file_path.NormalizePathSeparators();
+#endif // defined(FILE_PATH_USES_WIN_SEPARATORS)
root_hashes_[file_path] = std::string();
root_hashes_[file_path].swap(root_hash);
}
diff --git a/extensions/browser/verified_contents_unittest.cc b/extensions/browser/verified_contents_unittest.cc
index b4f2ecf..f52b74b 100644
--- a/extensions/browser/verified_contents_unittest.cc
+++ b/extensions/browser/verified_contents_unittest.cc
@@ -76,10 +76,13 @@ TEST(VerifiedContents, Simple) {
"txHiG5KQvNoPOSH5FbQo9Zb5gJ23j3oFB0Ru9DOnziw",
contents.GetTreeHashRoot(
base::FilePath::FromUTF8Unsafe("background.js"))));
- EXPECT_TRUE(Base64UrlStringEquals(
- "L37LFbT_hmtxRL7AfGZN9YTpW6yoz_ZiQ1opLJn1NZU",
- contents.GetTreeHashRoot(
- base::FilePath::FromUTF8Unsafe("foo/bar.html"))));
+
+ base::FilePath foo_bar_html =
+ base::FilePath(FILE_PATH_LITERAL("foo")).AppendASCII("bar.html");
+ EXPECT_FALSE(foo_bar_html.IsAbsolute());
+ EXPECT_TRUE(
+ Base64UrlStringEquals("L37LFbT_hmtxRL7AfGZN9YTpW6yoz_ZiQ1opLJn1NZU",
+ contents.GetTreeHashRoot(foo_bar_html)));
base::FilePath nonexistent = base::FilePath::FromUTF8Unsafe("nonexistent");
EXPECT_TRUE(contents.GetTreeHashRoot(nonexistent) == NULL);