@@ -595,7 +595,11 @@ def startTagScript(self, name, attributes):
595595
596596 def startTagBaseLinkMeta (self , name , attributes ):
597597 element = self .tree .createElement (name , attributes )
598- self .appendToHead (element )
598+ if (self .tree .headPointer is not None and
599+ self .parser .phase == self .parser .phases ["inHead" ]):
600+ self .appendToHead (element )
601+ else :
602+ self .tree .openElements [- 1 ].appendChild (element )
599603
600604 def startTagOther (self , name , attributes ):
601605 self .anythingElse ()
@@ -692,9 +696,9 @@ def __init__(self, parser, tree):
692696
693697 self .startTagHandler = utils .MethodDispatcher ([
694698 ("html" , self .startTagHtml ),
695- (("script " , "style" ), self . startTagScriptStyle ),
696- (( "base" , "link" , "meta" , "title" ),
697- self .startTagFromHead ),
699+ (("base " , "link" , "meta" , "script" , "style" ),
700+ self . startTagProcessInHead ),
701+ ( "title" , self .startTagTitle ),
698702 ("body" , self .startTagBody ),
699703 (("address" , "blockquote" , "center" , "dir" , "div" , "dl" ,
700704 "fieldset" , "listing" , "menu" , "ol" , "p" , "pre" , "ul" ),
@@ -779,10 +783,10 @@ def processCharacters(self, data):
779783 self .tree .reconstructActiveFormattingElements ()
780784 self .tree .insertText (data )
781785
782- def startTagScriptStyle (self , name , attributes ):
786+ def startTagProcessInHead (self , name , attributes ):
783787 self .parser .phases ["inHead" ].processStartTag (name , attributes )
784788
785- def startTagFromHead (self , name , attributes ):
789+ def startTagTitle (self , name , attributes ):
786790 self .parser .parseError (_ (u"Unexpected start tag (" + name + \
787791 ") that belongs in the head. Moved." ))
788792 self .parser .phases ["inHead" ].processStartTag (name , attributes )
0 commit comments