| OLD | NEW |
| 1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. | 13 // limitations under the License. |
| 14 | 14 |
| 15 #include "test/multiprocess_exec.h" | 15 #include "test/multiprocess_exec.h" |
| 16 | 16 |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #include "gtest/gtest.h" | 19 #include "gtest/gtest.h" |
| 20 #include "test/win/child_launcher.h" |
| 20 | 21 |
| 21 namespace crashpad { | 22 namespace crashpad { |
| 22 namespace test { | 23 namespace test { |
| 23 | 24 |
| 24 namespace { | |
| 25 | |
| 26 // Ref: http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/
everyone-quotes-arguments-the-wrong-way.aspx | |
| 27 void AppendCommandLineArgument(const std::wstring& argument, | |
| 28 std::wstring* command_line) { | |
| 29 // Don't bother quoting if unnecessary. | |
| 30 if (!argument.empty() && | |
| 31 argument.find_first_of(L" \t\n\v\"") == std::wstring::npos) { | |
| 32 command_line->append(argument); | |
| 33 } else { | |
| 34 command_line->push_back(L'"'); | |
| 35 for (std::wstring::const_iterator i = argument.begin();; ++i) { | |
| 36 size_t backslash_count = 0; | |
| 37 while (i != argument.end() && *i == L'\\') { | |
| 38 ++i; | |
| 39 ++backslash_count; | |
| 40 } | |
| 41 if (i == argument.end()) { | |
| 42 // Escape all backslashes, but let the terminating double quotation mark | |
| 43 // we add below be interpreted as a metacharacter. | |
| 44 command_line->append(backslash_count * 2, L'\\'); | |
| 45 break; | |
| 46 } else if (*i == L'"') { | |
| 47 // Escape all backslashes and the following double quotation mark. | |
| 48 command_line->append(backslash_count * 2 + 1, L'\\'); | |
| 49 command_line->push_back(*i); | |
| 50 } else { | |
| 51 // Backslashes aren't special here. | |
| 52 command_line->append(backslash_count, L'\\'); | |
| 53 command_line->push_back(*i); | |
| 54 } | |
| 55 } | |
| 56 command_line->push_back(L'"'); | |
| 57 } | |
| 58 } | |
| 59 | |
| 60 } // namespace | |
| 61 | |
| 62 namespace internal { | 25 namespace internal { |
| 63 | 26 |
| 64 struct MultiprocessInfo { | 27 struct MultiprocessInfo { |
| 65 MultiprocessInfo() {} | 28 MultiprocessInfo() {} |
| 66 ScopedFileHANDLE pipe_c2p_read; | 29 ScopedFileHANDLE pipe_c2p_read; |
| 67 ScopedFileHANDLE pipe_c2p_write; | 30 ScopedFileHANDLE pipe_c2p_write; |
| 68 ScopedFileHANDLE pipe_p2c_read; | 31 ScopedFileHANDLE pipe_p2c_read; |
| 69 ScopedFileHANDLE pipe_p2c_write; | 32 ScopedFileHANDLE pipe_p2c_write; |
| 70 PROCESS_INFORMATION process_info; | 33 PROCESS_INFORMATION process_info; |
| 71 }; | 34 }; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 TRUE, | 160 TRUE, |
| 198 0, | 161 0, |
| 199 nullptr, | 162 nullptr, |
| 200 nullptr, | 163 nullptr, |
| 201 &startup_info, | 164 &startup_info, |
| 202 &info()->process_info)); | 165 &info()->process_info)); |
| 203 } | 166 } |
| 204 | 167 |
| 205 } // namespace test | 168 } // namespace test |
| 206 } // namespace crashpad | 169 } // namespace crashpad |
| OLD | NEW |