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

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

Issue 8984007: Revert 114929 - Standardize StringToInt{,64} interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « net/ftp/ftp_util.cc ('k') | net/http/http_response_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) 2011 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 // Derived from: 5 // Derived from:
6 // mozilla/netwerk/protocol/http/src/nsHttpChunkedDecoder.cpp 6 // mozilla/netwerk/protocol/http/src/nsHttpChunkedDecoder.cpp
7 // The license block is: 7 // The license block is:
8 /* ***** BEGIN LICENSE BLOCK ***** 8 /* ***** BEGIN LICENSE BLOCK *****
9 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 9 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
10 * 10 *
11 * The contents of this file are subject to the Mozilla Public License Version 11 * The contents of this file are subject to the Mozilla Public License Version
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 // Us: ^\X+[ ]*$ 180 // Us: ^\X+[ ]*$
181 bool HttpChunkedDecoder::ParseChunkSize(const char* start, int len, int* out) { 181 bool HttpChunkedDecoder::ParseChunkSize(const char* start, int len, int* out) {
182 DCHECK(len >= 0); 182 DCHECK(len >= 0);
183 183
184 // Strip trailing spaces 184 // Strip trailing spaces
185 while (len && start[len - 1] == ' ') 185 while (len && start[len - 1] == ' ')
186 len--; 186 len--;
187 187
188 // Be more restrictive than HexStringToInt; 188 // Be more restrictive than HexStringToInt;
189 // don't allow inputs with leading "-", "+", "0x", "0X" 189 // don't allow inputs with leading "-", "+", "0x", "0X"
190 base::StringPiece chunk_size(start, len); 190 if (base::StringPiece(start, len).find_first_not_of("0123456789abcdefABCDEF")
191 if (chunk_size.find_first_not_of("0123456789abcdefABCDEF") 191 != base::StringPiece::npos)
192 != base::StringPiece::npos) {
193 return false; 192 return false;
194 }
195 193
196 int parsed_number; 194 int parsed_number;
197 bool ok = base::HexStringToInt(chunk_size, &parsed_number); 195 bool ok = base::HexStringToInt(start, start + len, &parsed_number);
198 if (ok && parsed_number >= 0) { 196 if (ok && parsed_number >= 0) {
199 *out = parsed_number; 197 *out = parsed_number;
200 return true; 198 return true;
201 } 199 }
202 return false; 200 return false;
203 } 201 }
204 202
205 } // namespace net 203 } // namespace net
OLDNEW
« no previous file with comments | « net/ftp/ftp_util.cc ('k') | net/http/http_response_headers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698