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

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

Issue 773373002: Update from https://crrev.com/306706 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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/mac/README » ('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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 0xffffffffL, 0xfc00987dL, 0x78000001L, 0xb8000001L, 311 0xffffffffL, 0xfc00987dL, 0x78000001L, 0xb8000001L,
312 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL 312 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL
313 }}; 313 }};
314 314
315 // non-printable, non-7bit, and (including space) "#%:<>?[\]^`{|} 315 // non-printable, non-7bit, and (including space) "#%:<>?[\]^`{|}
316 static const Charmap kPathCharmap = {{ 316 static const Charmap kPathCharmap = {{
317 0xffffffffL, 0xd400002dL, 0x78000000L, 0xb8000001L, 317 0xffffffffL, 0xd400002dL, 0x78000000L, 0xb8000001L,
318 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL 318 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL
319 }}; 319 }};
320 320
321 #if defined(OS_MACOSX)
322 // non-printable, non-7bit, and (including space) "#%<>[\]^`{|}
323 static const Charmap kNSURLCharmap = {{
324 0xffffffffL, 0x5000002dL, 0x78000000L, 0xb8000001L,
325 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL
326 }};
327 #endif // defined(OS_MACOSX)
328
321 // non-printable, non-7bit, and (including space) ?>=<;+'&%$#"![\]^`{|} 329 // non-printable, non-7bit, and (including space) ?>=<;+'&%$#"![\]^`{|}
322 static const Charmap kUrlEscape = {{ 330 static const Charmap kUrlEscape = {{
323 0xffffffffL, 0xf80008fdL, 0x78000001L, 0xb8000001L, 331 0xffffffffL, 0xf80008fdL, 0x78000001L, 0xb8000001L,
324 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL 332 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL
325 }}; 333 }};
326 334
327 // non-7bit 335 // non-7bit
328 static const Charmap kNonASCIICharmap = {{ 336 static const Charmap kNonASCIICharmap = {{
329 0x00000000L, 0x00000000L, 0x00000000L, 0x00000000L, 337 0x00000000L, 0x00000000L, 0x00000000L, 0x00000000L,
330 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL 338 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL
331 }}; 339 }};
332 340
333 // Everything except alphanumerics, the reserved characters(;/?:@&=+$,) and 341 // Everything except alphanumerics, the reserved characters(;/?:@&=+$,) and
334 // !'()*-._~#[] 342 // !'()*-._~#[]
335 static const Charmap kExternalHandlerCharmap = {{ 343 static const Charmap kExternalHandlerCharmap = {{
336 0xffffffffL, 0x50000025L, 0x50000000L, 0xb8000001L, 344 0xffffffffL, 0x50000025L, 0x50000000L, 0xb8000001L,
337 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL 345 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL
338 }}; 346 }};
339 347
340 } // namespace 348 } // namespace
341 349
342 std::string EscapeQueryParamValue(const std::string& text, bool use_plus) { 350 std::string EscapeQueryParamValue(const std::string& text, bool use_plus) {
343 return Escape(text, kQueryCharmap, use_plus); 351 return Escape(text, kQueryCharmap, use_plus);
344 } 352 }
345 353
346 std::string EscapePath(const std::string& path) { 354 std::string EscapePath(const std::string& path) {
347 return Escape(path, kPathCharmap, false); 355 return Escape(path, kPathCharmap, false);
348 } 356 }
349 357
358 #if defined(OS_MACOSX)
359 std::string EscapeNSURLPrecursor(const std::string& precursor) {
360 return Escape(precursor, kNSURLCharmap, false, true);
361 }
362 #endif // defined(OS_MACOSX)
363
350 std::string EscapeUrlEncodedData(const std::string& path, bool use_plus) { 364 std::string EscapeUrlEncodedData(const std::string& path, bool use_plus) {
351 return Escape(path, kUrlEscape, use_plus); 365 return Escape(path, kUrlEscape, use_plus);
352 } 366 }
353 367
354 std::string EscapeNonASCII(const std::string& input) { 368 std::string EscapeNonASCII(const std::string& input) {
355 return Escape(input, kNonASCIICharmap, false); 369 return Escape(input, kNonASCIICharmap, false);
356 } 370 }
357 371
358 std::string EscapeExternalHandlerValue(const std::string& text) { 372 std::string EscapeExternalHandlerValue(const std::string& text) {
359 return Escape(text, kExternalHandlerCharmap, false, true); 373 return Escape(text, kExternalHandlerCharmap, false, true);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 1, kEscapeToChars[i].replacement); 454 1, kEscapeToChars[i].replacement);
441 break; 455 break;
442 } 456 }
443 } 457 }
444 } 458 }
445 } 459 }
446 return text; 460 return text;
447 } 461 }
448 462
449 } // namespace net 463 } // namespace net
OLDNEW
« no previous file with comments | « net/base/escape.h ('k') | net/base/mac/README » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698