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

Side by Side Diff: net/http/http_content_disposition.cc

Issue 1200053004: Move more string_util functions to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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/cookies/cookie_util.cc ('k') | net/http/http_security_headers.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/http/http_content_disposition.h" 5 #include "net/http/http_content_disposition.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/string_tokenizer.h" 9 #include "base/strings/string_tokenizer.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 16 matching lines...) Expand all
27 // decoding a quoted-printable string. Returns true if the input was valid. 27 // decoding a quoted-printable string. Returns true if the input was valid.
28 bool DecodeQEncoding(const std::string& input, std::string* output) { 28 bool DecodeQEncoding(const std::string& input, std::string* output) {
29 std::string temp; 29 std::string temp;
30 temp.reserve(input.size()); 30 temp.reserve(input.size());
31 for (std::string::const_iterator it = input.begin(); it != input.end(); 31 for (std::string::const_iterator it = input.begin(); it != input.end();
32 ++it) { 32 ++it) {
33 if (*it == '_') { 33 if (*it == '_') {
34 temp.push_back(' '); 34 temp.push_back(' ');
35 } else if (*it == '=') { 35 } else if (*it == '=') {
36 if ((input.end() - it < 3) || 36 if ((input.end() - it < 3) ||
37 !IsHexDigit(static_cast<unsigned char>(*(it + 1))) || 37 !base::IsHexDigit(static_cast<unsigned char>(*(it + 1))) ||
38 !IsHexDigit(static_cast<unsigned char>(*(it + 2)))) 38 !base::IsHexDigit(static_cast<unsigned char>(*(it + 2))))
39 return false; 39 return false;
40 unsigned char ch = HexDigitToInt(*(it + 1)) * 16 + 40 unsigned char ch =
41 HexDigitToInt(*(it + 2)); 41 base::HexDigitToInt(*(it + 1)) * 16 + base::HexDigitToInt(*(it + 2));
42 temp.push_back(static_cast<char>(ch)); 42 temp.push_back(static_cast<char>(ch));
43 ++it; 43 ++it;
44 ++it; 44 ++it;
45 } else if (0x20 < *it && *it < 0x7F && *it != '?') { 45 } else if (0x20 < *it && *it < 0x7F && *it != '?') {
46 // In a Q-encoded word, only printable ASCII characters 46 // In a Q-encoded word, only printable ASCII characters
47 // represent themselves. Besides, space, '=', '_' and '?' are 47 // represent themselves. Besides, space, '=', '_' and '?' are
48 // not allowed, but they're already filtered out. 48 // not allowed, but they're already filtered out.
49 DCHECK_NE('=', *it); 49 DCHECK_NE('=', *it);
50 DCHECK_NE('?', *it); 50 DCHECK_NE('?', *it);
51 DCHECK_NE('_', *it); 51 DCHECK_NE('_', *it);
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 } 418 }
419 } 419 }
420 420
421 if (!ext_filename.empty()) 421 if (!ext_filename.empty())
422 filename_ = ext_filename; 422 filename_ = ext_filename;
423 else 423 else
424 filename_ = filename; 424 filename_ = filename;
425 } 425 }
426 426
427 } // namespace net 427 } // namespace net
OLDNEW
« no previous file with comments | « net/cookies/cookie_util.cc ('k') | net/http/http_security_headers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698