Chromium Code Reviews| 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 #include "components/url_formatter/url_fixer.h" | 5 #include "components/url_formatter/url_fixer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 613 if (gurl.is_valid() && gurl.IsStandard()) | 613 if (gurl.is_valid() && gurl.IsStandard()) |
| 614 is_file = false; | 614 is_file = false; |
| 615 base::FilePath full_path; | 615 base::FilePath full_path; |
| 616 if (is_file && !ValidPathForFile(trimmed, &full_path)) { | 616 if (is_file && !ValidPathForFile(trimmed, &full_path)) { |
| 617 // Not a path as entered, try unescaping it in case the user has | 617 // Not a path as entered, try unescaping it in case the user has |
| 618 // escaped things. We need to go through 8-bit since the escaped values | 618 // escaped things. We need to go through 8-bit since the escaped values |
| 619 // only represent 8-bit values. | 619 // only represent 8-bit values. |
| 620 #if defined(OS_WIN) | 620 #if defined(OS_WIN) |
| 621 std::wstring unescaped = base::UTF8ToWide(net::UnescapeURLComponent( | 621 std::wstring unescaped = base::UTF8ToWide(net::UnescapeURLComponent( |
| 622 base::WideToUTF8(trimmed), | 622 base::WideToUTF8(trimmed), |
| 623 net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS)); | 623 net::UnescapeRule::SPACES | net::UnescapeRule::PATH_SEPARATORS | |
| 624 net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS)); | |
|
mmenke
2016/03/16 21:30:01
Since this is only done on paths from the command
Peter Kasting
2016/03/17 06:03:02
I don't think I understand this comment: what does
mmenke
2016/03/17 09:23:21
A security problem. Applying this to file URLs ge
| |
| 624 #elif defined(OS_POSIX) | 625 #elif defined(OS_POSIX) |
| 625 std::string unescaped = net::UnescapeURLComponent( | 626 std::string unescaped = net::UnescapeURLComponent( |
| 626 trimmed, | 627 trimmed, |
| 627 net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS); | 628 net::UnescapeRule::SPACES | net::UnescapeRule::PATH_SEPARATORS | |
| 629 net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS); | |
| 628 #endif | 630 #endif |
| 629 | 631 |
| 630 if (!ValidPathForFile(unescaped, &full_path)) | 632 if (!ValidPathForFile(unescaped, &full_path)) |
| 631 is_file = false; | 633 is_file = false; |
| 632 } | 634 } |
| 633 | 635 |
| 634 // Put back the current directory if we saved it. | 636 // Put back the current directory if we saved it. |
| 635 if (!base_dir.empty()) | 637 if (!base_dir.empty()) |
| 636 base::SetCurrentDirectory(old_cur_directory); | 638 base::SetCurrentDirectory(old_cur_directory); |
| 637 | 639 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 668 } | 670 } |
| 669 | 671 |
| 670 bool IsEquivalentScheme(const std::string& scheme1, | 672 bool IsEquivalentScheme(const std::string& scheme1, |
| 671 const std::string& scheme2) { | 673 const std::string& scheme2) { |
| 672 return scheme1 == scheme2 || | 674 return scheme1 == scheme2 || |
| 673 (scheme1 == url::kAboutScheme && scheme2 == kChromeUIScheme) || | 675 (scheme1 == url::kAboutScheme && scheme2 == kChromeUIScheme) || |
| 674 (scheme1 == kChromeUIScheme && scheme2 == url::kAboutScheme); | 676 (scheme1 == kChromeUIScheme && scheme2 == url::kAboutScheme); |
| 675 } | 677 } |
| 676 | 678 |
| 677 } // namespace url_formatter | 679 } // namespace url_formatter |
| OLD | NEW |