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

Side by Side Diff: net/base/filename_util.cc

Issue 1704163003: FileURLToFilePath: Don't unescape '/' and '\\'. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Made comment less scary Created 4 years, 10 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
« no previous file with comments | « net/base/escape_unittest.cc ('k') | net/base/filename_util_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "net/base/filename_util.h" 5 #include "net/base/filename_util.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // TODO(dhg): This should probably take into account UNCs which could 91 // TODO(dhg): This should probably take into account UNCs which could
92 // include a hostname other than localhost or blank 92 // include a hostname other than localhost or blank
93 std::string path = url.path(); 93 std::string path = url.path();
94 #endif // !defined(OS_WIN) 94 #endif // !defined(OS_WIN)
95 95
96 if (path.empty()) 96 if (path.empty())
97 return false; 97 return false;
98 98
99 // GURL stores strings as percent-encoded 8-bit, this will undo if possible. 99 // GURL stores strings as percent-encoded 8-bit, this will undo if possible.
100 path = UnescapeURLComponent( 100 path = UnescapeURLComponent(
101 path, UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS); 101 path, UnescapeRule::SPACES |
102 UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS);
102 103
103 #if defined(OS_WIN) 104 #if defined(OS_WIN)
104 if (base::IsStringUTF8(path)) { 105 if (base::IsStringUTF8(path)) {
105 file_path_str.assign(base::UTF8ToWide(path)); 106 file_path_str.assign(base::UTF8ToWide(path));
106 // We used to try too hard and see if |path| made up entirely of 107 // We used to try too hard and see if |path| made up entirely of
107 // the 1st 256 characters in the Unicode was a zero-extended UTF-16. 108 // the 1st 256 characters in the Unicode was a zero-extended UTF-16.
108 // If so, we converted it to 'Latin-1' and checked if the result was UTF-8. 109 // If so, we converted it to 'Latin-1' and checked if the result was UTF-8.
109 // If the check passed, we converted the result to UTF-8. 110 // If the check passed, we converted the result to UTF-8.
110 // Otherwise, we treated the result as the native OS encoding. 111 // Otherwise, we treated the result as the native OS encoding.
111 // However, that led to http://crbug.com/4619 and http://crbug.com/14153 112 // However, that led to http://crbug.com/4619 and http://crbug.com/14153
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 187
187 for (size_t i = 0; i < arraysize(magic_names); ++i) { 188 for (size_t i = 0; i < arraysize(magic_names); ++i) {
188 if (filename_lower == magic_names[i]) 189 if (filename_lower == magic_names[i])
189 return true; 190 return true;
190 } 191 }
191 192
192 return false; 193 return false;
193 } 194 }
194 195
195 } // namespace net 196 } // namespace net
OLDNEW
« no previous file with comments | « net/base/escape_unittest.cc ('k') | net/base/filename_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698