From 4a39158368f6184c8d56e1d65866ba99f83297e0 Mon Sep 17 00:00:00 2001 From: Oystein Date: Tue, 22 Jul 2014 09:05:08 +0200 Subject: Added support for appending an escaped SegmentedString to another. Merge of blink r174725 This was previously an assert which triggers in the situation where the HTMLEntityParser is parsing a potential named entity, but only has one or two characters of data available due to being at the end of a network packet boundary, so it 'unconsumes' them from the SegmentedString which has some special handling when only one or two characters needs unconsuming to avoid string creation. Next time the tokenizer is pumped, the SegmentedString is then appended to the HTMLSourceTracker right before the actual parsing happens (i.e. when we'd consume the previously unconsumed characters). SegmentedString::append mostly assumes the parameter string hasn't been consumed from and had an assert instead of handling this case, which hits. Task-number: QTBUG-40284 Change-Id: Ifcf9af6f6e2e5a9750af4297cfda2f55f3bb274e Reviewed-by: Michael Bruning --- Source/WebCore/platform/text/SegmentedString.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Source/WebCore/platform/text/SegmentedString.cpp b/Source/WebCore/platform/text/SegmentedString.cpp index b0dc3d3dd..95de06ae4 100644 --- a/Source/WebCore/platform/text/SegmentedString.cpp +++ b/Source/WebCore/platform/text/SegmentedString.cpp @@ -166,7 +166,14 @@ void SegmentedString::close() void SegmentedString::append(const SegmentedString& s) { ASSERT(!m_closed); - ASSERT(!s.escaped()); + if (s.m_pushedChar1) { + Vector unconsumedData; + unconsumedData.append(s.m_pushedChar1); + if (s.m_pushedChar2) + unconsumedData.append(s.m_pushedChar2); + append(SegmentedSubstring(String(unconsumedData))); + } + append(s.m_currentString); if (s.isComposite()) { Deque::const_iterator it = s.m_substrings.begin(); @@ -174,7 +181,7 @@ void SegmentedString::append(const SegmentedString& s) for (; it != e; ++it) append(*it); } - m_currentChar = m_pushedChar1 ? m_pushedChar1 : (m_currentString.m_length ? m_currentString.getCurrentChar() : 0); + m_currentChar = m_currentString.m_length ? m_currentString.getCurrentChar() : 0; } void SegmentedString::prepend(const SegmentedString& s) -- cgit v1.2.3