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

Side by Side Diff: Source/core/html/track/WebVTTParser.cpp

Issue 22304002: Crash when calling getCueAsHTML() on a TextTrackCue with empty text (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated Created 7 years, 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 return BadCue; 321 return BadCue;
322 return Id; 322 return Id;
323 } 323 }
324 324
325 PassRefPtr<DocumentFragment> WebVTTParser::createDocumentFragmentFromCueText(co nst String& text) 325 PassRefPtr<DocumentFragment> WebVTTParser::createDocumentFragmentFromCueText(co nst String& text)
326 { 326 {
327 // Cue text processing based on 327 // Cue text processing based on
328 // 4.8.10.13.4 WebVTT cue text parsing rules and 328 // 4.8.10.13.4 WebVTT cue text parsing rules and
329 // 4.8.10.13.5 WebVTT cue text DOM construction rules. 329 // 4.8.10.13.5 WebVTT cue text DOM construction rules.
330 330
331 if (!text.length())
332 return 0;
333
334 ASSERT(m_scriptExecutionContext->isDocument()); 331 ASSERT(m_scriptExecutionContext->isDocument());
335 Document* document = toDocument(m_scriptExecutionContext); 332 Document* document = toDocument(m_scriptExecutionContext);
336 333
337 RefPtr<DocumentFragment> fragment = DocumentFragment::create(document); 334 RefPtr<DocumentFragment> fragment = DocumentFragment::create(document);
335
336 if (!text.length()) {
337 fragment->parserAppendChild(Text::create(document, ""));
338 return fragment;
339 }
340
338 m_currentNode = fragment; 341 m_currentNode = fragment;
339 m_tokenizer->reset(); 342 m_tokenizer->reset();
340 m_token.clear(); 343 m_token.clear();
341 344
342 m_languageStack.clear(); 345 m_languageStack.clear();
343 SegmentedString content(text); 346 SegmentedString content(text);
344 while (m_tokenizer->nextToken(content, m_token)) 347 while (m_tokenizer->nextToken(content, m_token))
345 constructTreeFromToken(document); 348 constructTreeFromToken(document);
346 349
347 return fragment.release(); 350 return fragment.release();
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 unsigned oldPosition = *position; 565 unsigned oldPosition = *position;
563 while (*position < length && data[*position] != '\r' && data[*position] != ' \n') 566 while (*position < length && data[*position] != '\r' && data[*position] != ' \n')
564 (*position)++; 567 (*position)++;
565 String line = String::fromUTF8(data + oldPosition, *position - oldPosition); 568 String line = String::fromUTF8(data + oldPosition, *position - oldPosition);
566 skipLineTerminator(data, length, position); 569 skipLineTerminator(data, length, position);
567 return line; 570 return line;
568 } 571 }
569 572
570 } 573 }
571 574
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698