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

Side by Side Diff: chrome/test/base/v8_unit_test.cc

Issue 11782005: Don't allow path traversal paths on the base file helpers (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/platform_file_win.cc ('k') | skia/ext/vector_canvas_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/test/base/v8_unit_test.h" 5 #include "chrome/test/base/v8_unit_test.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/string_piece.h" 10 #include "base/string_piece.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 user_libraries_.begin(); 61 user_libraries_.begin();
62 user_libraries_iterator != user_libraries_.end(); 62 user_libraries_iterator != user_libraries_.end();
63 ++user_libraries_iterator) { 63 ++user_libraries_iterator) {
64 std::string library_content; 64 std::string library_content;
65 FilePath library_file(*user_libraries_iterator); 65 FilePath library_file(*user_libraries_iterator);
66 if (!user_libraries_iterator->IsAbsolute()) { 66 if (!user_libraries_iterator->IsAbsolute()) {
67 FilePath gen_file = gen_test_data_directory.Append(library_file); 67 FilePath gen_file = gen_test_data_directory.Append(library_file);
68 library_file = file_util::PathExists(gen_file) ? gen_file : 68 library_file = file_util::PathExists(gen_file) ? gen_file :
69 test_data_directory.Append(*user_libraries_iterator); 69 test_data_directory.Append(*user_libraries_iterator);
70 } 70 }
71 file_util::AbsolutePath(&library_file);
71 if (!file_util::ReadFileToString(library_file, &library_content)) { 72 if (!file_util::ReadFileToString(library_file, &library_content)) {
72 ADD_FAILURE() << library_file.value(); 73 ADD_FAILURE() << library_file.value();
73 return false; 74 return false;
74 } 75 }
75 ExecuteScriptInContext(library_content, library_file.MaybeAsASCII()); 76 ExecuteScriptInContext(library_content, library_file.MaybeAsASCII());
76 if (::testing::Test::HasFatalFailure()) 77 if (::testing::Test::HasFatalFailure())
77 return false; 78 return false;
78 } 79 }
79 return true; 80 return true;
80 } 81 }
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 EXPECT_EQ(2U, testResult->Length()); 264 EXPECT_EQ(2U, testResult->Length());
264 if (::testing::Test::HasNonfatalFailure()) 265 if (::testing::Test::HasNonfatalFailure())
265 return v8::Undefined(); 266 return v8::Undefined();
266 testResult_ok = testResult->Get(0)->BooleanValue(); 267 testResult_ok = testResult->Get(0)->BooleanValue();
267 if (!testResult_ok) { 268 if (!testResult_ok) {
268 v8::String::Utf8Value message(testResult->Get(1)); 269 v8::String::Utf8Value message(testResult->Get(1));
269 LOG(ERROR) << *message; 270 LOG(ERROR) << *message;
270 } 271 }
271 return v8::Undefined(); 272 return v8::Undefined();
272 } 273 }
OLDNEW
« no previous file with comments | « base/platform_file_win.cc ('k') | skia/ext/vector_canvas_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698