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

Side by Side Diff: net/tools/dump_cache/url_utilities.cc

Issue 1841863002: Update monet. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 4 years, 8 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/tools/dump_cache/url_utilities.h" 5 #include "net/tools/dump_cache/url_utilities.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 10
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 case NORMAL: 80 case NORMAL:
81 if (c == '%') { 81 if (c == '%') {
82 escape_text.clear(); 82 escape_text.clear();
83 state = ESCAPE1; 83 state = ESCAPE1;
84 } else { 84 } else {
85 unescaped_url.push_back(c); 85 unescaped_url.push_back(c);
86 } 86 }
87 ++iter; 87 ++iter;
88 break; 88 break;
89 case ESCAPE1: 89 case ESCAPE1:
90 if (IsHexDigit(c)) { 90 if (base::IsHexDigit(c)) {
91 escape_text.push_back(c); 91 escape_text.push_back(c);
92 state = ESCAPE2; 92 state = ESCAPE2;
93 ++iter; 93 ++iter;
94 } else { 94 } else {
95 // Unexpected, % followed by non-hex chars, pass it through. 95 // Unexpected, % followed by non-hex chars, pass it through.
96 unescaped_url.push_back('%'); 96 unescaped_url.push_back('%');
97 state = NORMAL; 97 state = NORMAL;
98 } 98 }
99 break; 99 break;
100 case ESCAPE2: 100 case ESCAPE2:
101 if (IsHexDigit(c)) { 101 if (base::IsHexDigit(c)) {
102 escape_text.push_back(c); 102 escape_text.push_back(c);
103 bool ok = base::HexStringToInt(escape_text, &escape_value); 103 bool ok = base::HexStringToInt(escape_text, &escape_value);
104 DCHECK(ok); 104 DCHECK(ok);
105 unescaped_url.push_back(static_cast<unsigned char>(escape_value)); 105 unescaped_url.push_back(static_cast<unsigned char>(escape_value));
106 state = NORMAL; 106 state = NORMAL;
107 ++iter; 107 ++iter;
108 } else { 108 } else {
109 // Unexpected, % followed by non-hex chars, pass it through. 109 // Unexpected, % followed by non-hex chars, pass it through.
110 unescaped_url.push_back('%'); 110 unescaped_url.push_back('%');
111 unescaped_url.append(escape_text); 111 unescaped_url.append(escape_text);
112 state = NORMAL; 112 state = NORMAL;
113 } 113 }
114 break; 114 break;
115 } 115 }
116 } 116 }
117 // Unexpected, % followed by end of string, pass it through. 117 // Unexpected, % followed by end of string, pass it through.
118 if (state == ESCAPE1 || state == ESCAPE2) { 118 if (state == ESCAPE1 || state == ESCAPE2) {
119 unescaped_url.push_back('%'); 119 unescaped_url.push_back('%');
120 unescaped_url.append(escape_text); 120 unescaped_url.append(escape_text);
121 } 121 }
122 return unescaped_url; 122 return unescaped_url;
123 } 123 }
124 124
125 } // namespace net 125 } // namespace net
126 126
OLDNEW
« no previous file with comments | « net/tools/dump_cache/url_to_filename_encoder_unittest.cc ('k') | net/tools/flip_server/mem_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698