Changeset 51101 in webkit


Ignore:
Timestamp:
Nov 17, 2009 9:19:24 PM (14 years ago)
Author:
tkent@chromium.org
Message:

2009-11-17 Hayato Ito <hayato@google.com>

Reviewed by Darin Adler.

Avoid infinite mutual recursion when deeply nested tags are loaded
https://bugs.webkit.org/show_bug.cgi?id=30651

  • fast/parser/block-nesting-cap-table-expected.txt: Added.
  • fast/parser/block-nesting-cap-table.html: Added.
  • fast/parser/script-tests/block-nesting-cap-table.js: Added.

2009-11-17 Hayato Ito <hayato@google.com>

Reviewed by Darin Adler.

Avoid infinite mutual recursion when deeply nested tags are loaded
https://bugs.webkit.org/show_bug.cgi?id=30651

Test: fast/parser/block-nesting-cap-table.html

  • html/HTMLParser.cpp: (WebCore::HTMLParser::parseToken): (WebCore::tagPriorityOfNode): (WebCore::HTMLParser::limitBlockDepth): (WebCore::HTMLParser::insertNodeAfterLimitBlockDepth): (WebCore::HTMLParser::insertNode):
  • html/HTMLParser.h:
Location:
trunk
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r51097 r51101  
     12009-11-17  Hayato Ito  <hayato@google.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Avoid infinite mutual recursion when deeply nested tags are loaded
     6        https://bugs.webkit.org/show_bug.cgi?id=30651
     7
     8        * fast/parser/block-nesting-cap-table-expected.txt: Added.
     9        * fast/parser/block-nesting-cap-table.html: Added.
     10        * fast/parser/script-tests/block-nesting-cap-table.js: Added.
     11
    1122009-11-17  Johnny Ding  <jnd@chromium.org>
    213
  • trunk/WebCore/ChangeLog

    r51098 r51101  
     12009-11-17  Hayato Ito  <hayato@google.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Avoid infinite mutual recursion when deeply nested tags are loaded
     6        https://bugs.webkit.org/show_bug.cgi?id=30651
     7
     8        Test: fast/parser/block-nesting-cap-table.html
     9
     10        * html/HTMLParser.cpp:
     11        (WebCore::HTMLParser::parseToken):
     12        (WebCore::tagPriorityOfNode):
     13        (WebCore::HTMLParser::limitBlockDepth):
     14        (WebCore::HTMLParser::insertNodeAfterLimitBlockDepth):
     15        (WebCore::HTMLParser::insertNode):
     16        * html/HTMLParser.h:
     17
    1182009-11-17  Brent Fulgham  <bfulgham@webkit.org>
    219
  • trunk/WebCore/html/HTMLParser.cpp

    r47489 r51101  
    204204}
    205205
     206inline static int tagPriorityOfNode(Node* n)
     207{
     208    return n->isHTMLElement() ? static_cast<HTMLElement*>(n)->tagPriority() : 0;
     209}
     210
     211inline void HTMLParser::limitBlockDepth(int tagPriority)
     212{
     213    if (tagPriority >= minBlockLevelTagPriority) {
     214        while (m_blocksInStack >= cMaxBlockDepth)
     215            popBlock(m_blockStack->tagName);
     216    }
     217}
     218
     219inline bool HTMLParser::insertNodeAfterLimitBlockDepth(Node* n, bool flat)
     220{
     221    limitBlockDepth(tagPriorityOfNode(n));
     222    return insertNode(n, flat);
     223}
     224
    206225PassRefPtr<Node> HTMLParser::parseToken(Token* t)
    207226{
     
    242261            // split large blocks of text to nodes of manageable size
    243262            n = Text::createWithLengthLimit(m_document, text, charsLeft);
    244             if (!insertNode(n.get(), t->selfClosingTag))
     263            if (!insertNodeAfterLimitBlockDepth(n.get(), t->selfClosingTag))
    245264                return 0;
    246265        }
     
    272291    }
    273292
    274     if (!insertNode(n.get(), t->selfClosingTag)) {
     293    if (!insertNodeAfterLimitBlockDepth(n.get(), t->selfClosingTag)) {
    275294        // we couldn't insert the node
    276295
     
    330349
    331350    const AtomicString& localName = n->localName();
    332     int tagPriority = n->isHTMLElement() ? static_cast<HTMLElement*>(n)->tagPriority() : 0;
    333351   
    334352    // <table> is never allowed inside stray table content.  Always pop out of the stray table content
     
    337355        popBlock(tableTag);
    338356
    339     if (tagPriority >= minBlockLevelTagPriority) {
    340         while (m_blocksInStack >= cMaxBlockDepth)
    341             popBlock(m_blockStack->tagName);
    342     }
    343 
    344357    if (m_parserQuirks && !m_parserQuirks->shouldInsertNode(m_current, n))
    345358        return false;
     359
     360    int tagPriority = tagPriorityOfNode(n);
    346361
    347362    // let's be stupid and just try to insert it.
  • trunk/WebCore/html/HTMLParser.h

    r45891 r51101  
    112112    void processCloseTag(Token*);
    113113
     114    void limitBlockDepth(int tagPriority);
     115
     116    bool insertNodeAfterLimitBlockDepth(Node*, bool flat = false);
    114117    bool insertNode(Node*, bool flat = false);
    115118    bool handleError(Node*, bool flat, const AtomicString& localName, int tagPriority);
Note: See TracChangeset for help on using the changeset viewer.