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

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

Issue 8418034: Make string_util::WriteInto() DCHECK() that the supplied |length_with_null| > 1, meaning that the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/net_util.h" 5 #include "net/base/net_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <map> 9 #include <map>
10 10
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } else { 202 } else {
203 return false; 203 return false;
204 } 204 }
205 ++it; 205 ++it;
206 } 206 }
207 output->swap(temp); 207 output->swap(temp);
208 return true; 208 return true;
209 } 209 }
210 210
211 enum RFC2047EncodingType {Q_ENCODING, B_ENCODING}; 211 enum RFC2047EncodingType {Q_ENCODING, B_ENCODING};
212 bool DecodeBQEncoding(const std::string& part, RFC2047EncodingType enc_type, 212 bool DecodeBQEncoding(const std::string& part,
213 const std::string& charset, std::string* output) { 213 RFC2047EncodingType enc_type,
214 const std::string& charset,
215 std::string* output) {
216 DCHECK(!part.empty()); // TODO(pkasting): Not sure about this.
214 std::string decoded; 217 std::string decoded;
215 if (enc_type == B_ENCODING) { 218 if (enc_type == B_ENCODING) {
216 if (!base::Base64Decode(part, &decoded)) { 219 if (!base::Base64Decode(part, &decoded)) {
217 return false; 220 return false;
218 } 221 }
219 } else { 222 } else {
220 if (!QPDecode(part, &decoded)) { 223 if (!QPDecode(part, &decoded)) {
221 return false; 224 return false;
222 } 225 }
223 } 226 }
227 DCHECK(!decoded.empty());
224 228
225 UErrorCode err = U_ZERO_ERROR; 229 UErrorCode err = U_ZERO_ERROR;
226 UConverter* converter(ucnv_open(charset.c_str(), &err)); 230 UConverter* converter(ucnv_open(charset.c_str(), &err));
227 if (U_FAILURE(err)) { 231 if (U_FAILURE(err)) {
228 return false; 232 return false;
229 } 233 }
230 234
231 // A single byte in a legacy encoding can be expanded to 3 bytes in UTF-8. 235 // A single byte in a legacy encoding can be expanded to 3 bytes in UTF-8.
232 // A 'two-byte character' in a legacy encoding can be expanded to 4 bytes 236 // A 'two-byte character' in a legacy encoding can be expanded to 4 bytes
233 // in UTF-8. Therefore, the expansion ratio is 3 at most. 237 // in UTF-8. Therefore, the expansion ratio is 3 at most.
(...skipping 2217 matching lines...) Expand 10 before | Expand all | Expand 10 after
2451 2455
2452 NetworkInterface::NetworkInterface(const std::string& name, 2456 NetworkInterface::NetworkInterface(const std::string& name,
2453 const IPAddressNumber& address) 2457 const IPAddressNumber& address)
2454 : name(name), address(address) { 2458 : name(name), address(address) {
2455 } 2459 }
2456 2460
2457 NetworkInterface::~NetworkInterface() { 2461 NetworkInterface::~NetworkInterface() {
2458 } 2462 }
2459 2463
2460 } // namespace net 2464 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698