| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/resource_provider/file_utils.h" | 5 #include "components/resource_provider/file_utils.h" |
| 6 | 6 |
| 7 #include <stddef.h> |
| 8 |
| 7 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 8 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 9 #include "base/strings/string_split.h" | 11 #include "base/strings/string_split.h" |
| 10 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "build/build_config.h" |
| 11 | 14 |
| 12 namespace resource_provider { | 15 namespace resource_provider { |
| 13 namespace { | 16 namespace { |
| 14 | 17 |
| 15 bool IsPathNameValid(const std::string& name) { | 18 bool IsPathNameValid(const std::string& name) { |
| 16 if (name.empty() || name == "." || name == "..") | 19 if (name.empty() || name == "." || name == "..") |
| 17 return false; | 20 return false; |
| 18 | 21 |
| 19 for (auto c : name) { | 22 for (auto c : name) { |
| 20 if (!base::IsAsciiAlpha(c) && !base::IsAsciiDigit(c) && | 23 if (!base::IsAsciiAlpha(c) && !base::IsAsciiDigit(c) && |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 base::FilePath result(app_path); | 92 base::FilePath result(app_path); |
| 90 for (const auto& path_component : path_components) { | 93 for (const auto& path_component : path_components) { |
| 91 if (!IsPathNameValid(path_component)) | 94 if (!IsPathNameValid(path_component)) |
| 92 return base::FilePath(); | 95 return base::FilePath(); |
| 93 result = result.AppendASCII(path_component); | 96 result = result.AppendASCII(path_component); |
| 94 } | 97 } |
| 95 return result; | 98 return result; |
| 96 } | 99 } |
| 97 | 100 |
| 98 } // namespace resource_provider | 101 } // namespace resource_provider |
| OLD | NEW |