Changeset 60802 in webkit
- Timestamp:
- Jun 7, 2010, 2:53:13 PM (15 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r60801 r60802 1 2010-06-07 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 Fix XFrameOptions and xssAuditor crashes in HTML5 parser 6 https://bugs.webkit.org/show_bug.cgi?id=40265 7 8 We're not supposed to call end() while the tokenizer's write() method. 9 This causes a bunch of LayoutTests to crash. In particular, this patch 10 fixes crashes in the following tests: 11 12 Tests: 13 * http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-in-body.html 14 * http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-parent-same-origin-deny.html 15 * http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag.html 16 * http/tests/security/xssAuditor/full-block-base-href.html 17 * http/tests/security/xssAuditor/full-block-get-from-iframe.html 18 * http/tests/security/xssAuditor/full-block-iframe-javascript-url.html 19 * http/tests/security/xssAuditor/full-block-link-onclick.html 20 * http/tests/security/xssAuditor/full-block-post-from-iframe.html 21 * http/tests/security/xssAuditor/full-block-script-tag.html 22 * http/tests/security/xssAuditor/xss-protection-parsing-01.html 23 24 * html/HTML5Tokenizer.cpp: 25 (WebCore::): 26 (WebCore::HTML5Tokenizer::HTML5Tokenizer): 27 (WebCore::HTML5Tokenizer::write): 28 (WebCore::HTML5Tokenizer::attemptToEnd): 29 (WebCore::HTML5Tokenizer::endIfDelayed): 30 (WebCore::HTML5Tokenizer::finish): 31 (WebCore::HTML5Tokenizer::resumeParsingAfterScriptExecution): 32 * html/HTML5Tokenizer.h: 33 (WebCore::HTML5Tokenizer::inWrite): 34 1 35 2010-06-07 Eric Seidel <eric@webkit.org> 2 36 -
trunk/WebCore/html/HTML5Tokenizer.cpp
r60801 r60802 38 38 namespace WebCore { 39 39 40 namespace { 41 42 class NestingLevelIncrementer : public Noncopyable { 43 public: 44 NestingLevelIncrementer(int& counter) 45 : m_counter(&counter) 46 { 47 ++(*m_counter); 48 } 49 50 ~NestingLevelIncrementer() 51 { 52 --(*m_counter); 53 } 54 55 private: 56 int* m_counter; 57 }; 58 59 } // namespace 60 40 61 HTML5Tokenizer::HTML5Tokenizer(HTMLDocument* document, bool reportErrors) 41 62 : Tokenizer() … … 44 65 , m_scriptRunner(new HTML5ScriptRunner(document, this)) 45 66 , m_treeBuilder(new HTML5TreeBuilder(m_lexer.get(), document, reportErrors)) 46 , m_wasWaitingOnScriptsDuringFinish(false) 67 , m_endWasDelayed(false) 68 , m_writeNestingLevel(0) 47 69 { 48 70 begin(); … … 51 73 HTML5Tokenizer::~HTML5Tokenizer() 52 74 { 75 ASSERT(!m_endWasDelayed); 53 76 } 54 77 … … 81 104 void HTML5Tokenizer::write(const SegmentedString& source, bool) 82 105 { 106 NestingLevelIncrementer nestingLevelIncrementer(m_writeNestingLevel); 107 83 108 // HTML5Tokenizer::executeScript is responsible for handling saving m_source before re-entry. 84 109 m_source.append(source); 85 110 if (!m_treeBuilder->isPaused()) 86 111 pumpLexer(); 112 113 endIfDelayed(); 87 114 } 88 115 … … 95 122 } 96 123 97 void HTML5Tokenizer:: finish()124 void HTML5Tokenizer::attemptToEnd() 98 125 { 99 126 // finish() indicates we will not receive any more data. If we are waiting on 100 127 // an external script to load, we can't finish parsing quite yet. 101 if (isWaitingForScripts()) { 102 // FIXME: We might want to use real state enum instead of a bool here. 103 m_wasWaitingOnScriptsDuringFinish = true; 104 return; 105 } 128 129 if (inWrite() || isWaitingForScripts()) { 130 m_endWasDelayed = true; 131 return; 132 } 133 106 134 // We can't call m_source.close() yet as we may have a <script> execution 107 135 // pending which will call document.write(). No more data off the network though. 108 136 end(); 137 } 138 139 void HTML5Tokenizer::endIfDelayed() 140 { 141 if (!m_endWasDelayed || !m_source.isEmpty() || isWaitingForScripts() || executingScript()) 142 return; 143 144 m_endWasDelayed = false; 145 end(); 146 } 147 148 void HTML5Tokenizer::finish() 149 { 150 attemptToEnd(); 109 151 } 110 152 … … 135 177 pumpLexer(); 136 178 ASSERT(m_treeBuilder->isPaused() || m_source.isEmpty()); 137 if (m_source.isEmpty() && m_wasWaitingOnScriptsDuringFinish)138 end(); // The document already finished parsing we were just waiting on scripts when finished() was called.179 // The document already finished parsing we were just waiting on scripts when finished() was called. 180 endIfDelayed(); 139 181 } 140 182 -
trunk/WebCore/html/HTML5Tokenizer.h
r60553 r60802 73 73 void resumeParsingAfterScriptExecution(); 74 74 75 void attemptToEnd(); 76 void endIfDelayed(); 77 bool inWrite() const { return m_writeNestingLevel > 0; } 78 75 79 SegmentedString m_source; 76 80 … … 82 86 OwnPtr<HTML5ScriptRunner> m_scriptRunner; 83 87 OwnPtr<HTML5TreeBuilder> m_treeBuilder; 84 bool m_wasWaitingOnScriptsDuringFinish; 88 bool m_endWasDelayed; 89 int m_writeNestingLevel; 85 90 }; 86 91
Note:
See TracChangeset
for help on using the changeset viewer.