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

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

Issue 42013: Slight code change to make some global variables const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « net/base/escape_unittest.cc ('k') | net/base/mime_util.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // Detecting mime types is a tricky business because we need to balance 5 // Detecting mime types is a tricky business because we need to balance
6 // compatibility concerns with security issues. Here is a survey of how other 6 // compatibility concerns with security issues. Here is a survey of how other
7 // browsers behave and then a description of how we intend to behave. 7 // browsers behave and then a description of how we intend to behave.
8 // 8 //
9 // HTML payload, no Content-Type header: 9 // HTML payload, no Content-Type header:
10 // * IE 7: Render as HTML 10 // * IE 7: Render as HTML
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 const int kMaxTagIterations = 5; 325 const int kMaxTagIterations = 5;
326 for (int i = 0; i < kMaxTagIterations && pos < end; ++i) { 326 for (int i = 0; i < kMaxTagIterations && pos < end; ++i) {
327 pos = reinterpret_cast<const char*>(memchr(pos, '<', end - pos)); 327 pos = reinterpret_cast<const char*>(memchr(pos, '<', end - pos));
328 if (!pos) 328 if (!pos)
329 return false; 329 return false;
330 330
331 if (base::strncasecmp(pos, "<?xml", sizeof("<?xml")-1) == 0) { 331 if (base::strncasecmp(pos, "<?xml", sizeof("<?xml")-1) == 0) {
332 // Skip XML declarations. 332 // Skip XML declarations.
333 ++pos; 333 ++pos;
334 continue; 334 continue;
335 } else if (base::strncasecmp(pos, "<!DOCTYPE", sizeof("<!DOCTYPE")-1) == 0) { 335 } else if (base::strncasecmp(pos, "<!DOCTYPE",
336 sizeof("<!DOCTYPE")-1) == 0) {
336 // Skip DOCTYPE declarations. 337 // Skip DOCTYPE declarations.
337 ++pos; 338 ++pos;
338 continue; 339 continue;
339 } 340 }
340 341
341 if (CheckForMagicNumbers(pos, end - pos, 342 if (CheckForMagicNumbers(pos, end - pos,
342 kMagicXML, arraysize(kMagicXML), 343 kMagicXML, arraysize(kMagicXML),
343 &counter, result)) 344 &counter, result))
344 return true; 345 return true;
345 346
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 result->assign("text/plain"); 549 result->assign("text/plain");
549 // We could change our mind if a binary-looking byte appears later in 550 // We could change our mind if a binary-looking byte appears later in
550 // the content, so we only have enough content if we have the max. 551 // the content, so we only have enough content if we have the max.
551 return content_size >= kMaxBytesToSniff; 552 return content_size >= kMaxBytesToSniff;
552 } 553 }
553 554
554 return have_enough_content; 555 return have_enough_content;
555 } 556 }
556 557
557 } // namespace net 558 } // namespace net
OLDNEW
« no previous file with comments | « net/base/escape_unittest.cc ('k') | net/base/mime_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698