@@ -257,19 +257,6 @@ def emitCurrentToken(self):
257257 self .tokenQueue .append (self .currentToken )
258258 self .state = self .states ["data" ]
259259
260- def attributeValueQuotedStateHandler (self , quoteType ):
261- data = self .stream .char ()
262- if data == quoteType :
263- self .state = self .states ["beforeAttributeName" ]
264- elif data == u"&" :
265- self .processEntityInAttribute ()
266- elif data == EOF :
267- self .tokenQueue .append ({"type" : "ParseError" , "data" :
268- _ ("Unexpected end of file in attribute value." )})
269- self .emitCurrentToken ()
270- else :
271- self .currentToken ["data" ][- 1 ][1 ] += data + self .stream .charsUntil (\
272- (quoteType , u"&" ))
273260
274261 # Below are the various tokenizer states worked out.
275262
@@ -567,14 +554,33 @@ def beforeAttributeValueState(self):
567554 return True
568555
569556 def attributeValueDoubleQuotedState (self ):
570- # AT We could also let self.attributeValueQuotedStateHandler always
571- # return true and then return that directly here. Not sure what is
572- # faster or better...
573- self .attributeValueQuotedStateHandler (u"\" " )
557+ data = self .stream .char ()
558+ if data == "\" " :
559+ self .state = self .states ["beforeAttributeName" ]
560+ elif data == u"&" :
561+ self .processEntityInAttribute ()
562+ elif data == EOF :
563+ self .tokenQueue .append ({"type" : "ParseError" , "data" :
564+ _ ("Unexpected end of file in attribute value (\" )." )})
565+ self .emitCurrentToken ()
566+ else :
567+ self .currentToken ["data" ][- 1 ][1 ] += data + \
568+ self .stream .charsUntil (("\" " , u"&" ))
574569 return True
575570
576571 def attributeValueSingleQuotedState (self ):
577- self .attributeValueQuotedStateHandler (u"'" )
572+ data = self .stream .char ()
573+ if data == "'" :
574+ self .state = self .states ["beforeAttributeName" ]
575+ elif data == u"&" :
576+ self .processEntityInAttribute ()
577+ elif data == EOF :
578+ self .tokenQueue .append ({"type" : "ParseError" , "data" :
579+ _ ("Unexpected end of file in attribute value (')." )})
580+ self .emitCurrentToken ()
581+ else :
582+ self .currentToken ["data" ][- 1 ][1 ] += data + \
583+ self .stream .charsUntil (("'" , u"&" ))
578584 return True
579585
580586 def attributeValueUnQuotedState (self ):
0 commit comments