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

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: Fix typo 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
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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 > ' ' && (rules & UnescapeRule::URL_SPECIAL_CHARS)) ||
294 (first_byte > ' ' && first_byte != '/' && first_byte != '\\' &&
295 (rules & UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPERATORS)) ||
294 // Additionally allow non-display characters if requested. 296 // Additionally allow non-display characters if requested.
295 (first_byte < ' ' && 297 (first_byte < ' ' &&
296 (rules & UnescapeRule::SPOOFING_AND_CONTROL_CHARS)))) { 298 (rules & UnescapeRule::SPOOFING_AND_CONTROL_CHARS)))) {
297 // Use the unescaped version of the character. 299 // Use the unescaped version of the character.
298 if (adjustments) 300 if (adjustments)
299 adjustments->push_back(base::OffsetAdjuster::Adjustment(i, 3, 1)); 301 adjustments->push_back(base::OffsetAdjuster::Adjustment(i, 3, 1));
300 result.push_back(first_byte); 302 result.push_back(first_byte);
301 i += 2; 303 i += 2;
302 } else { 304 } else {
303 // Keep escaped. Append a percent and we'll get the following two 305 // 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); 503 1, kEscapeToChars[i].replacement);
502 break; 504 break;
503 } 505 }
504 } 506 }
505 } 507 }
506 } 508 }
507 return text; 509 return text;
508 } 510 }
509 511
510 } // namespace net 512 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698