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

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

Issue 747773002: Upstream "nsurl_util.{h,mm}" from Chrome on iOS repository. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from mmenke. 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
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 // non-printable, non-7bit, and (including space) "#%<>[\]^`{|}
322 static const Charmap kNSURLCharmap = {{
323 0xffffffffL, 0x5000002dL, 0x78000000L, 0xb8000001L,
324 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL
325 }};
326
321 // non-printable, non-7bit, and (including space) ?>=<;+'&%$#"![\]^`{|} 327 // non-printable, non-7bit, and (including space) ?>=<;+'&%$#"![\]^`{|}
322 static const Charmap kUrlEscape = {{ 328 static const Charmap kUrlEscape = {{
323 0xffffffffL, 0xf80008fdL, 0x78000001L, 0xb8000001L, 329 0xffffffffL, 0xf80008fdL, 0x78000001L, 0xb8000001L,
324 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL 330 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL
325 }}; 331 }};
326 332
327 // non-7bit 333 // non-7bit
328 static const Charmap kNonASCIICharmap = {{ 334 static const Charmap kNonASCIICharmap = {{
329 0x00000000L, 0x00000000L, 0x00000000L, 0x00000000L, 335 0x00000000L, 0x00000000L, 0x00000000L, 0x00000000L,
330 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL 336 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL
331 }}; 337 }};
332 338
333 // Everything except alphanumerics, the reserved characters(;/?:@&=+$,) and 339 // Everything except alphanumerics, the reserved characters(;/?:@&=+$,) and
334 // !'()*-._~#[] 340 // !'()*-._~#[]
335 static const Charmap kExternalHandlerCharmap = {{ 341 static const Charmap kExternalHandlerCharmap = {{
336 0xffffffffL, 0x50000025L, 0x50000000L, 0xb8000001L, 342 0xffffffffL, 0x50000025L, 0x50000000L, 0xb8000001L,
337 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL 343 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL
338 }}; 344 }};
339 345
340 } // namespace 346 } // namespace
341 347
342 std::string EscapeQueryParamValue(const std::string& text, bool use_plus) { 348 std::string EscapeQueryParamValue(const std::string& text, bool use_plus) {
343 return Escape(text, kQueryCharmap, use_plus); 349 return Escape(text, kQueryCharmap, use_plus);
344 } 350 }
345 351
346 std::string EscapePath(const std::string& path) { 352 std::string EscapePath(const std::string& path) {
347 return Escape(path, kPathCharmap, false); 353 return Escape(path, kPathCharmap, false);
348 } 354 }
349 355
356 std::string EscapeNSURLPrecursor(const std::string& precursor) {
357 return Escape(precursor, kNSURLCharmap, false, true);
358 }
359
350 std::string EscapeUrlEncodedData(const std::string& path, bool use_plus) { 360 std::string EscapeUrlEncodedData(const std::string& path, bool use_plus) {
351 return Escape(path, kUrlEscape, use_plus); 361 return Escape(path, kUrlEscape, use_plus);
352 } 362 }
353 363
354 std::string EscapeNonASCII(const std::string& input) { 364 std::string EscapeNonASCII(const std::string& input) {
355 return Escape(input, kNonASCIICharmap, false); 365 return Escape(input, kNonASCIICharmap, false);
356 } 366 }
357 367
358 std::string EscapeExternalHandlerValue(const std::string& text) { 368 std::string EscapeExternalHandlerValue(const std::string& text) {
359 return Escape(text, kExternalHandlerCharmap, false, true); 369 return Escape(text, kExternalHandlerCharmap, false, true);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 1, kEscapeToChars[i].replacement); 450 1, kEscapeToChars[i].replacement);
441 break; 451 break;
442 } 452 }
443 } 453 }
444 } 454 }
445 } 455 }
446 return text; 456 return text;
447 } 457 }
448 458
449 } // namespace net 459 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698