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

Side by Side Diff: third_party/WebKit/Source/core/html/parser/HTMLConstructionSite.cpp

Issue 1670203002: Block HTML Imports from loading when inserted via innerHTML. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved.
3 * Copyright (C) 2011 Apple Inc. All rights reserved. 3 * Copyright (C) 2011 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 20 matching lines...) Expand all
31 #include "core/dom/Comment.h" 31 #include "core/dom/Comment.h"
32 #include "core/dom/DocumentFragment.h" 32 #include "core/dom/DocumentFragment.h"
33 #include "core/dom/DocumentType.h" 33 #include "core/dom/DocumentType.h"
34 #include "core/dom/Element.h" 34 #include "core/dom/Element.h"
35 #include "core/dom/ScriptLoader.h" 35 #include "core/dom/ScriptLoader.h"
36 #include "core/dom/TemplateContentDocumentFragment.h" 36 #include "core/dom/TemplateContentDocumentFragment.h"
37 #include "core/dom/Text.h" 37 #include "core/dom/Text.h"
38 #include "core/frame/LocalFrame.h" 38 #include "core/frame/LocalFrame.h"
39 #include "core/html/HTMLFormElement.h" 39 #include "core/html/HTMLFormElement.h"
40 #include "core/html/HTMLHtmlElement.h" 40 #include "core/html/HTMLHtmlElement.h"
41 #include "core/html/HTMLLinkElement.h"
41 #include "core/html/HTMLPlugInElement.h" 42 #include "core/html/HTMLPlugInElement.h"
42 #include "core/html/HTMLScriptElement.h" 43 #include "core/html/HTMLScriptElement.h"
43 #include "core/html/HTMLTemplateElement.h" 44 #include "core/html/HTMLTemplateElement.h"
44 #include "core/html/parser/AtomicHTMLToken.h" 45 #include "core/html/parser/AtomicHTMLToken.h"
45 #include "core/html/parser/HTMLParserIdioms.h" 46 #include "core/html/parser/HTMLParserIdioms.h"
46 #include "core/html/parser/HTMLStackItem.h" 47 #include "core/html/parser/HTMLStackItem.h"
47 #include "core/html/parser/HTMLToken.h" 48 #include "core/html/parser/HTMLToken.h"
48 #include "core/loader/FrameLoader.h" 49 #include "core/loader/FrameLoader.h"
49 #include "core/loader/FrameLoaderClient.h" 50 #include "core/loader/FrameLoaderClient.h"
50 #include "core/svg/SVGScriptElement.h" 51 #include "core/svg/SVGScriptElement.h"
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 void HTMLConstructionSite::insertHTMLElement(AtomicHTMLToken* token) 620 void HTMLConstructionSite::insertHTMLElement(AtomicHTMLToken* token)
620 { 621 {
621 RefPtrWillBeRawPtr<HTMLElement> element = createHTMLElement(token); 622 RefPtrWillBeRawPtr<HTMLElement> element = createHTMLElement(token);
622 attachLater(currentNode(), element); 623 attachLater(currentNode(), element);
623 m_openElements.push(HTMLStackItem::create(element.release(), token)); 624 m_openElements.push(HTMLStackItem::create(element.release(), token));
624 } 625 }
625 626
626 void HTMLConstructionSite::insertSelfClosingHTMLElementDestroyingToken(AtomicHTM LToken* token) 627 void HTMLConstructionSite::insertSelfClosingHTMLElementDestroyingToken(AtomicHTM LToken* token)
627 { 628 {
628 ASSERT(token->type() == HTMLToken::StartTag); 629 ASSERT(token->type() == HTMLToken::StartTag);
630
631 // Link tags require special processing in order to ensure that they don't e xecute script when
632 // they ought not to.
633 if (token->name() == linkTag) {
634 insertLinkElement(token);
dglazkov 2016/02/05 18:25:53 Would it be better to just split linkTag from http
635 return;
636 }
637
629 // Normally HTMLElementStack is responsible for calling finishParsingChildre n, 638 // Normally HTMLElementStack is responsible for calling finishParsingChildre n,
630 // but self-closing elements are never in the element stack so the stack 639 // but self-closing elements are never in the element stack so the stack
631 // doesn't get a chance to tell them that we're done parsing their children. 640 // doesn't get a chance to tell them that we're done parsing their children.
632 attachLater(currentNode(), createHTMLElement(token), true); 641 attachLater(currentNode(), createHTMLElement(token), true);
633 // FIXME: Do we want to acknowledge the token's self-closing flag? 642 // FIXME: Do we want to acknowledge the token's self-closing flag?
634 // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization. html#acknowledge-self-closing-flag 643 // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization. html#acknowledge-self-closing-flag
635 } 644 }
636 645
637 void HTMLConstructionSite::insertFormattingElement(AtomicHTMLToken* token) 646 void HTMLConstructionSite::insertFormattingElement(AtomicHTMLToken* token)
638 { 647 {
(...skipping 13 matching lines...) Expand all
652 // those flags or effects thereof. 661 // those flags or effects thereof.
653 const bool parserInserted = m_parserContentPolicy != AllowScriptingContentAn dDoNotMarkAlreadyStarted; 662 const bool parserInserted = m_parserContentPolicy != AllowScriptingContentAn dDoNotMarkAlreadyStarted;
654 const bool alreadyStarted = m_isParsingFragment && parserInserted; 663 const bool alreadyStarted = m_isParsingFragment && parserInserted;
655 RefPtrWillBeRawPtr<HTMLScriptElement> element = HTMLScriptElement::create(ow nerDocumentForCurrentNode(), parserInserted, alreadyStarted); 664 RefPtrWillBeRawPtr<HTMLScriptElement> element = HTMLScriptElement::create(ow nerDocumentForCurrentNode(), parserInserted, alreadyStarted);
656 setAttributes(element.get(), token, m_parserContentPolicy); 665 setAttributes(element.get(), token, m_parserContentPolicy);
657 if (scriptingContentIsAllowed(m_parserContentPolicy)) 666 if (scriptingContentIsAllowed(m_parserContentPolicy))
658 attachLater(currentNode(), element); 667 attachLater(currentNode(), element);
659 m_openElements.push(HTMLStackItem::create(element.release(), token)); 668 m_openElements.push(HTMLStackItem::create(element.release(), token));
660 } 669 }
661 670
671 void HTMLConstructionSite::insertLinkElement(AtomicHTMLToken* token)
672 {
673 // We use the same 'alreadyStarted' flag for link elements as we do for scri pt elements. That isn't
674 // in the HTML spec, or in the HTML Imports spec, but we need it for sane be havior in the latter.
675 //
676 // See 'insertScriptElement()' above for detail.
677 const bool parserInserted = m_parserContentPolicy != AllowScriptingContentAn dDoNotMarkAlreadyStarted;
kouhei (in TOK) 2016/02/08 01:30:24 I'm not sure if we should respect "AllowScriptingC
678 const bool alreadyStarted = m_isParsingFragment && parserInserted;
679 RefPtrWillBeRawPtr<HTMLLinkElement> element = HTMLLinkElement::create(ownerD ocumentForCurrentNode(), parserInserted, alreadyStarted);
680 setAttributes(element.get(), token, m_parserContentPolicy);
681 attachLater(currentNode(), element, true);
682 }
683
662 void HTMLConstructionSite::insertForeignElement(AtomicHTMLToken* token, const At omicString& namespaceURI) 684 void HTMLConstructionSite::insertForeignElement(AtomicHTMLToken* token, const At omicString& namespaceURI)
663 { 685 {
664 ASSERT(token->type() == HTMLToken::StartTag); 686 ASSERT(token->type() == HTMLToken::StartTag);
665 notImplemented(); // parseError when xmlns or xmlns:xlink are wrong. 687 notImplemented(); // parseError when xmlns or xmlns:xlink are wrong.
666 688
667 RefPtrWillBeRawPtr<Element> element = createElement(token, namespaceURI); 689 RefPtrWillBeRawPtr<Element> element = createElement(token, namespaceURI);
668 if (scriptingContentIsAllowed(m_parserContentPolicy) || !toScriptLoaderIfPos sible(element.get())) 690 if (scriptingContentIsAllowed(m_parserContentPolicy) || !toScriptLoaderIfPos sible(element.get()))
669 attachLater(currentNode(), element, token->selfClosing()); 691 attachLater(currentNode(), element, token->selfClosing());
670 if (!token->selfClosing()) 692 if (!token->selfClosing())
671 m_openElements.push(HTMLStackItem::create(element.release(), token, name spaceURI)); 693 m_openElements.push(HTMLStackItem::create(element.release(), token, name spaceURI));
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 queueTask(task); 893 queueTask(task);
872 } 894 }
873 895
874 DEFINE_TRACE(HTMLConstructionSite::PendingText) 896 DEFINE_TRACE(HTMLConstructionSite::PendingText)
875 { 897 {
876 visitor->trace(parent); 898 visitor->trace(parent);
877 visitor->trace(nextChild); 899 visitor->trace(nextChild);
878 } 900 }
879 901
880 } // namespace blink 902 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698