| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 #include <dirent.h> | 6 #include <dirent.h> |
| 7 | 7 |
| 8 extern "C" { | 8 extern "C" { |
| 9 #include <sandbox.h> | 9 #include <sandbox.h> |
| 10 } | 10 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 EXPECT_TRUE(Sandbox::QuoteStringForRegex(ok_string, &out)); | 92 EXPECT_TRUE(Sandbox::QuoteStringForRegex(ok_string, &out)); |
| 93 } | 93 } |
| 94 | 94 |
| 95 // Check that all characters whose values are larger than 126 [7E] are | 95 // Check that all characters whose values are larger than 126 [7E] are |
| 96 // rejected by the regex escaping code. | 96 // rejected by the regex escaping code. |
| 97 { | 97 { |
| 98 std::string out; | 98 std::string out; |
| 99 EXPECT_TRUE(Sandbox::QuoteStringForRegex("}", &out)); // } == 0x7D == 125 | 99 EXPECT_TRUE(Sandbox::QuoteStringForRegex("}", &out)); // } == 0x7D == 125 |
| 100 EXPECT_FALSE(Sandbox::QuoteStringForRegex("~", &out)); // ~ == 0x7E == 126 | 100 EXPECT_FALSE(Sandbox::QuoteStringForRegex("~", &out)); // ~ == 0x7E == 126 |
| 101 EXPECT_FALSE( | 101 EXPECT_FALSE( |
| 102 Sandbox::QuoteStringForRegex(WideToUTF8(L"^\u2135.\u2136$"), &out)); | 102 Sandbox::QuoteStringForRegex(base::WideToUTF8(L"^\u2135.\u2136$"), |
| 103 &out)); |
| 103 } | 104 } |
| 104 | 105 |
| 105 { | 106 { |
| 106 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(regex_cases); ++i) { | 107 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(regex_cases); ++i) { |
| 107 std::string out; | 108 std::string out; |
| 108 std::string in = WideToUTF8(regex_cases[i].to_escape); | 109 std::string in = base::WideToUTF8(regex_cases[i].to_escape); |
| 109 EXPECT_TRUE(Sandbox::QuoteStringForRegex(in, &out)); | 110 EXPECT_TRUE(Sandbox::QuoteStringForRegex(in, &out)); |
| 110 std::string expected("^"); | 111 std::string expected("^"); |
| 111 expected.append(regex_cases[i].escaped); | 112 expected.append(regex_cases[i].escaped); |
| 112 expected.append(kSandboxEscapeSuffix); | 113 expected.append(kSandboxEscapeSuffix); |
| 113 EXPECT_EQ(expected, out); | 114 EXPECT_EQ(expected, out); |
| 114 } | 115 } |
| 115 } | 116 } |
| 116 | 117 |
| 117 { | 118 { |
| 118 std::string in_utf8("\\^.$|()[]*+?{}"); | 119 std::string in_utf8("\\^.$|()[]*+?{}"); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 PLOG(ERROR) << "Sandbox breach: was able to write (" | 304 PLOG(ERROR) << "Sandbox breach: was able to write (" |
| 304 << denied_file2.value() | 305 << denied_file2.value() |
| 305 << ")"; | 306 << ")"; |
| 306 return -1; | 307 return -1; |
| 307 } | 308 } |
| 308 | 309 |
| 309 return 0; | 310 return 0; |
| 310 } | 311 } |
| 311 | 312 |
| 312 } // namespace content | 313 } // namespace content |
| OLD | NEW |