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

Side by Side Diff: net/base/escape.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.h ('k') | net/base/escape_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 (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 "net/base/escape.h" 5 #include "net/base/escape.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 } 283 }
284 } 284 }
285 285
286 if (first_byte >= 0x80 || // Unescape all high-bit characters. 286 if (first_byte >= 0x80 || // Unescape all high-bit characters.
287 // For 7-bit characters, the lookup table tells us all valid chars. 287 // For 7-bit characters, the lookup table tells us all valid chars.
288 (kUrlUnescape[first_byte] || 288 (kUrlUnescape[first_byte] ||
289 // ...and we allow some additional unescaping when flags are set. 289 // ...and we allow some additional unescaping when flags are set.
290 (first_byte == ' ' && (rules & UnescapeRule::SPACES)) || 290 (first_byte == ' ' && (rules & UnescapeRule::SPACES)) ||
291 // Allow any of the prohibited but non-control characters when 291 // Allow any of the prohibited but non-control characters when
292 // we're doing "special" chars. 292 // we're doing "special" chars.
293 (first_byte > ' ' && (rules & UnescapeRule::URL_SPECIAL_CHARS)) || 293 ((first_byte == '/' || first_byte == '\\') &&
294 (rules & UnescapeRule::PATH_SEPARATORS)) ||
295 (first_byte > ' ' && first_byte != '/' && first_byte != '\\' &&
296 (rules & UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS)) ||
294 // Additionally allow non-display characters if requested. 297 // Additionally allow non-display characters if requested.
295 (first_byte < ' ' && 298 (first_byte < ' ' &&
296 (rules & UnescapeRule::SPOOFING_AND_CONTROL_CHARS)))) { 299 (rules & UnescapeRule::SPOOFING_AND_CONTROL_CHARS)))) {
297 // Use the unescaped version of the character. 300 // Use the unescaped version of the character.
298 if (adjustments) 301 if (adjustments)
299 adjustments->push_back(base::OffsetAdjuster::Adjustment(i, 3, 1)); 302 adjustments->push_back(base::OffsetAdjuster::Adjustment(i, 3, 1));
300 result.push_back(first_byte); 303 result.push_back(first_byte);
301 i += 2; 304 i += 2;
302 } else { 305 } else {
303 // Keep escaped. Append a percent and we'll get the following two 306 // Keep escaped. Append a percent and we'll get the following two
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 1, kEscapeToChars[i].replacement); 504 1, kEscapeToChars[i].replacement);
502 break; 505 break;
503 } 506 }
504 } 507 }
505 } 508 }
506 } 509 }
507 return text; 510 return text;
508 } 511 }
509 512
510 } // namespace net 513 } // namespace net
OLDNEW
« no previous file with comments | « net/base/escape.h ('k') | net/base/escape_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698