Changeset 65382 in webkit


Ignore:
Timestamp:
Aug 15, 2010 12:43:17 PM (14 years ago)
Author:
abarth@webkit.org
Message:

2010-08-15 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

document.write() doesn't flush plain text
https://bugs.webkit.org/show_bug.cgi?id=8961

Add test cases for flushing character tokens.

  • fast/tokenizer/flush-characters-in-document-write-evil-expected.txt: Added.
  • fast/tokenizer/flush-characters-in-document-write-evil.html: Added.
  • fast/tokenizer/flush-characters-in-document-write-expected.txt: Added.
  • fast/tokenizer/flush-characters-in-document-write.html: Added.

2010-08-15 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

document.write() doesn't flush plain text
https://bugs.webkit.org/show_bug.cgi?id=8961

Originally I thought we should buffer the character tokens until we've
reached the end of the input stream, but that's not how the spec
handles things (it emits the character tokens one-by-one).

Tests: fast/tokenizer/flush-characters-in-document-write-evil.html

fast/tokenizer/flush-characters-in-document-write.html

  • html/HTMLTokenizer.cpp: (WebCore::HTMLTokenizer::emitEndOfFile): (WebCore::HTMLTokenizer::nextToken): (WebCore::HTMLTokenizer::haveBufferedCharacterToken):
    • Renamed this function now that it's simplier.
  • html/HTMLTokenizer.h:
Location:
trunk
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r65381 r65382  
     12010-08-15  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        document.write() doesn't flush plain text
     6        https://bugs.webkit.org/show_bug.cgi?id=8961
     7
     8        Add test cases for flushing character tokens.
     9
     10        * fast/tokenizer/flush-characters-in-document-write-evil-expected.txt: Added.
     11        * fast/tokenizer/flush-characters-in-document-write-evil.html: Added.
     12        * fast/tokenizer/flush-characters-in-document-write-expected.txt: Added.
     13        * fast/tokenizer/flush-characters-in-document-write.html: Added.
     14
    1152010-08-15  Adam Barth  <abarth@webkit.org>
    216
  • trunk/WebCore/ChangeLog

    r65381 r65382  
     12010-08-15  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        document.write() doesn't flush plain text
     6        https://bugs.webkit.org/show_bug.cgi?id=8961
     7
     8        Originally I thought we should buffer the character tokens until we've
     9        reached the end of the input stream, but that's not how the spec
     10        handles things (it emits the character tokens one-by-one).
     11
     12        Tests: fast/tokenizer/flush-characters-in-document-write-evil.html
     13               fast/tokenizer/flush-characters-in-document-write.html
     14
     15        * html/HTMLTokenizer.cpp:
     16        (WebCore::HTMLTokenizer::emitEndOfFile):
     17        (WebCore::HTMLTokenizer::nextToken):
     18        (WebCore::HTMLTokenizer::haveBufferedCharacterToken):
     19            - Renamed this function now that it's simplier.
     20        * html/HTMLTokenizer.h:
     21
    1222010-08-15  Adam Barth  <abarth@webkit.org>
    223
  • trunk/WebCore/html/HTMLTokenizer.cpp

    r65110 r65382  
    153153        m_state = stateName;                                               \
    154154        if (!m_inputStreamPreprocessor.advance(source, m_lineNumber))      \
    155             return shouldEmitBufferedCharacterToken(source);               \
     155            return haveBufferedCharacterToken();                           \
    156156        cc = m_inputStreamPreprocessor.nextInputCharacter();               \
    157157        goto stateName;                                                    \
     
    166166        m_state = stateName;                                               \
    167167        if (source.isEmpty() || !m_inputStreamPreprocessor.peek(source, m_lineNumber)) \
    168             return shouldEmitBufferedCharacterToken(source);               \
     168            return haveBufferedCharacterToken();                           \
    169169        cc = m_inputStreamPreprocessor.nextInputCharacter();               \
    170170        goto stateName;                                                    \
     
    203203bool HTMLTokenizer::emitEndOfFile(SegmentedString& source)
    204204{
    205     if (shouldEmitBufferedCharacterToken(source))
     205    if (haveBufferedCharacterToken())
    206206        return true;
    207207    m_state = DataState;
     
    230230        if (source.isEmpty()                                               \
    231231            || !m_inputStreamPreprocessor.peek(source, m_lineNumber))      \
    232             return shouldEmitBufferedCharacterToken(source);               \
     232            return haveBufferedCharacterToken();                           \
    233233        cc = m_inputStreamPreprocessor.nextInputCharacter();               \
    234234        goto stateName;                                                    \
     
    261261
    262262    if (source.isEmpty() || !m_inputStreamPreprocessor.peek(source, m_lineNumber))
    263         return shouldEmitBufferedCharacterToken(source);
     263        return haveBufferedCharacterToken();
    264264    UChar cc = m_inputStreamPreprocessor.nextInputCharacter();
    265265
     
    309309    BEGIN_STATE(CharacterReferenceInDataState) {
    310310        if (!processEntity(source))
    311             return shouldEmitBufferedCharacterToken(source);
     311            return haveBufferedCharacterToken();
    312312        SWITCH_TO(DataState);
    313313    }
     
    330330    BEGIN_STATE(CharacterReferenceInRCDATAState) {
    331331        if (!processEntity(source))
    332             return shouldEmitBufferedCharacterToken(source);
     332            return haveBufferedCharacterToken();
    333333        SWITCH_TO(RCDATAState);
    334334    }
     
    10301030        unsigned value = consumeHTMLEntity(source, notEnoughCharacters, m_additionalAllowedCharacter);
    10311031        if (notEnoughCharacters)
    1032             return shouldEmitBufferedCharacterToken(source);
     1032            return haveBufferedCharacterToken();
    10331033        if (!value)
    10341034            m_token->appendToAttributeValue('&');
     
    11141114                SWITCH_TO(CommentStartState);
    11151115            } else if (result == SegmentedString::NotEnoughCharacters)
    1116                 return shouldEmitBufferedCharacterToken(source);
     1116                return haveBufferedCharacterToken();
    11171117        } else if (cc == 'D' || cc == 'd') {
    11181118            SegmentedString::LookAheadResult result = source.lookAheadIgnoringCase(doctypeString);
     
    11211121                SWITCH_TO(DOCTYPEState);
    11221122            } else if (result == SegmentedString::NotEnoughCharacters)
    1123                 return shouldEmitBufferedCharacterToken(source);
     1123                return haveBufferedCharacterToken();
    11241124        }
    11251125        notImplemented();
     
    13341334                    SWITCH_TO(AfterDOCTYPEPublicKeywordState);
    13351335                } else if (result == SegmentedString::NotEnoughCharacters)
    1336                     return shouldEmitBufferedCharacterToken(source);
     1336                    return haveBufferedCharacterToken();
    13371337            } else if (cc == 'S' || cc == 's') {
    13381338                SegmentedString::LookAheadResult result = source.lookAheadIgnoringCase(systemString);
     
    13411341                    SWITCH_TO(AfterDOCTYPESystemKeywordState);
    13421342                } else if (result == SegmentedString::NotEnoughCharacters)
    1343                     return shouldEmitBufferedCharacterToken(source);
     1343                    return haveBufferedCharacterToken();
    13441344            }
    13451345            parseError();
     
    16501650}
    16511651
    1652 inline bool HTMLTokenizer::shouldEmitBufferedCharacterToken(const SegmentedString& source)
    1653 {
    1654     return source.isClosed() && m_token->type() == HTMLToken::Character;
    1655 }
    1656 
    1657 }
    1658 
     1652inline bool HTMLTokenizer::haveBufferedCharacterToken()
     1653{
     1654    return m_token->type() == HTMLToken::Character;
     1655}
     1656
     1657}
  • trunk/WebCore/html/HTMLTokenizer.h

    r65077 r65382  
    255255    inline bool isAppropriateEndTag();
    256256
    257     inline bool shouldEmitBufferedCharacterToken(const SegmentedString&);
     257    inline bool haveBufferedCharacterToken();
    258258
    259259    State m_state;
Note: See TracChangeset for help on using the changeset viewer.