@@ -257,19 +257,6 @@ def emitCurrentToken(self):
257
257
self .tokenQueue .append (self .currentToken )
258
258
self .state = self .states ["data" ]
259
259
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"&" ))
273
260
274
261
# Below are the various tokenizer states worked out.
275
262
@@ -567,14 +554,33 @@ def beforeAttributeValueState(self):
567
554
return True
568
555
569
556
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"&" ))
574
569
return True
575
570
576
571
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"&" ))
578
584
return True
579
585
580
586
def attributeValueUnQuotedState (self ):
0 commit comments