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

Side by Side Diff: third_party/WebKit/Source/core/html/parser/HTMLParserIdioms.cpp

Issue 1694773002: Check length of String before checking if it's 8/16 bit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add CORE_EXPORT Created 4 years, 10 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 /* 1 /*
2 * Copyright (C) 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 numbers.append(checkDoubleValue(number, parsedLength != 0, 0)); 302 numbers.append(checkDoubleValue(number, parsedLength != 0, 0));
303 303
304 skipWhile<CharacterType, isSpaceOrDelimiter>(position, end); 304 skipWhile<CharacterType, isSpaceOrDelimiter>(position, end);
305 } 305 }
306 return numbers; 306 return numbers;
307 } 307 }
308 308
309 // https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing- a-list-of-floating-point-numbers 309 // https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing- a-list-of-floating-point-numbers
310 Vector<double> parseHTMLListOfFloatingPointNumbers(const String& input) 310 Vector<double> parseHTMLListOfFloatingPointNumbers(const String& input)
311 { 311 {
312 if (input.is8Bit()) 312 unsigned length = input.length();
313 return parseHTMLListOfFloatingPointNumbersInternal(input.characters8(), input.characters8() + input.length()); 313 if (!length || input.is8Bit())
314 return parseHTMLListOfFloatingPointNumbersInternal(input.characters16(), inp ut.characters16() + input.length()); 314 return parseHTMLListOfFloatingPointNumbersInternal(input.characters8(), input.characters8() + length);
315 return parseHTMLListOfFloatingPointNumbersInternal(input.characters16(), inp ut.characters16() + length);
315 } 316 }
316 317
317 static const char charsetString[] = "charset"; 318 static const char charsetString[] = "charset";
318 static const size_t charsetLength = sizeof("charset") - 1; 319 static const size_t charsetLength = sizeof("charset") - 1;
319 320
320 String extractCharset(const String& value) 321 String extractCharset(const String& value)
321 { 322 {
322 size_t pos = 0; 323 size_t pos = 0;
323 unsigned length = value.length(); 324 unsigned length = value.length();
324 325
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 string = StringImpl::create8BitIfPossible(characters, size); 460 string = StringImpl::create8BitIfPossible(characters, size);
460 else if (width == Force8Bit) 461 else if (width == Force8Bit)
461 string = String::make8BitFrom16BitSource(characters, size); 462 string = String::make8BitFrom16BitSource(characters, size);
462 else 463 else
463 string = String(characters, size); 464 string = String(characters, size);
464 465
465 return string; 466 return string;
466 } 467 }
467 468
468 } // namespace blink 469 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698