Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Unified Diff: webkit/database/database_util_unittest.cc

Issue 12212091: WebDatabase: check path traversal in origin_identifier (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more testcases Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/database/database_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/database/database_util_unittest.cc
diff --git a/webkit/database/database_util_unittest.cc b/webkit/database/database_util_unittest.cc
index 18c701402c5e3a33fb8722a8f349e3804ce4a187..aa9d007ac9494f3a388bd6195936a204221c6173 100644
--- a/webkit/database/database_util_unittest.cc
+++ b/webkit/database/database_util_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/string_piece.h"
#include "base/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/database/database_util.h"
@@ -31,6 +32,12 @@ static GURL ToAndFromOriginIdentifier(const GURL origin_url) {
return DatabaseUtil::GetOriginFromIdentifier(id);
}
+static void TestValidOriginIdentifier(bool expected_result,
+ const base::StringPiece id) {
+ EXPECT_EQ(expected_result,
+ DatabaseUtil::IsValidOriginIdentifier(ASCIIToUTF16(id)));
+}
+
namespace webkit_database {
// Test DatabaseUtil::CrackVfsFilePath on various inputs.
@@ -54,4 +61,13 @@ TEST(DatabaseUtilTest, OriginIdentifiers) {
EXPECT_EQ(kHttpOrigin, ToAndFromOriginIdentifier(kHttpOrigin));
}
+TEST(DatabaseUtilTest, IsValidOriginIdentifier) {
+ TestValidOriginIdentifier(true, "http_bar_0");
+ TestValidOriginIdentifier(true, "");
+ TestValidOriginIdentifier(false, "bad..id");
+ TestValidOriginIdentifier(false, "bad/id");
+ TestValidOriginIdentifier(false, "bad\\id");
+ TestValidOriginIdentifier(false, base::StringPiece("bad\0id", 6));
+}
+
} // namespace webkit_database
« no previous file with comments | « webkit/database/database_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698