Commit 6521b2fc authored by proberge's avatar proberge Committed by Commit Bot

Extension content verifier: ignore empty relative paths

Some extensions make a request to "/" which confuses the extension
content verifier and causes it to mark the extension as corrupted.

Bug: 791929
Change-Id: Id594bd714048d33ddcf88fa86b26ce0a7696503c
Reviewed-on: https://chromium-review.googlesource.com/809225
Commit-Queue: proberge <proberge@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521777}
parent 68fea56e
......@@ -79,7 +79,11 @@ bool ContentHashReader::Init() {
if (!verified_contents.HasTreeHashRoot(relative_path_)) {
// Making a request to a non-existent resource should not result in
// content verification failure.
if (!base::PathExists(extension_root_.Append(relative_path_)))
// TODO(proberge): The relative_path_.empty() check should be moved higher
// in the execution flow for performance wins by saving on costly IO
// operations and calculations.
if (relative_path_.empty() ||
!base::PathExists(extension_root_.Append(relative_path_)))
file_missing_from_verified_contents_ = true;
return false;
......
......@@ -207,6 +207,17 @@ TEST_F(ContentVerifyJobUnittest, DeletedAndMissingFiles) {
RunContentVerifyJob(*extension.get(), unexpected_resource_path,
contents));
}
{
// Ask for the root path of the extension (i.e., chrome-extension://<id>/).
// Verification should skip this request as if the resource were
// non-existent. See https://crbug.com/791929.
base::FilePath empty_path_resource_path(FILE_PATH_LITERAL(""));
std::string empty_contents;
EXPECT_EQ(ContentVerifyJob::NONE,
RunContentVerifyJob(*extension.get(), empty_path_resource_path,
empty_contents));
}
}
// Tests that content modification causes content verification failure.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment