@@ -114,11 +114,19 @@ def processSolidusInTag(self):
114114 an EmptyTag
115115 """
116116
117+ rv = False
118+
117119 # We need to consume another character to make sure it's a ">"
118120 data = self .stream .char ()
119121
120122 if self .currentToken ["type" ] == "StartTag" and data == u">" :
121123 self .currentToken ["type" ] = "EmptyTag"
124+ elif data == EOF :
125+ self .tokenQueue .append ({"type" : "ParseError" , "data" :
126+ "EOF following solidus" })
127+ self .state = self .states ["data" ]
128+ self .emitCurrentToken ()
129+ rv = True
122130 else :
123131 self .tokenQueue .append ({"type" : "ParseError" , "data" :
124132 "incorrectly-placed-solidus" })
@@ -127,6 +135,8 @@ def processSolidusInTag(self):
127135 # doesn't get lost...
128136 self .stream .unget (data )
129137
138+ return rv
139+
130140 def consumeNumberEntity (self , isHex ):
131141 """This function returns either U+FFFD or the character based on the
132142 decimal or hexadecimal representation. It also discards ";" if present.
@@ -524,8 +534,8 @@ def attributeNameState(self):
524534 elif data in spaceCharacters :
525535 self .state = self .states ["afterAttributeName" ]
526536 elif data == u"/" :
527- self .processSolidusInTag ()
528- self .state = self .states ["beforeAttributeName" ]
537+ if not self .processSolidusInTag ():
538+ self .state = self .states ["beforeAttributeName" ]
529539 elif data == u"'" or data == u'"' :
530540 self .tokenQueue .append ({"type" : "ParseError" , "data" :
531541 "invalid-character-in-attribute-name" })
@@ -569,8 +579,8 @@ def afterAttributeNameState(self):
569579 self .currentToken ["data" ].append ([data , "" ])
570580 self .state = self .states ["attributeName" ]
571581 elif data == u"/" :
572- self .processSolidusInTag ()
573- self .state = self .states ["beforeAttributeName" ]
582+ if not self .processSolidusInTag ():
583+ self .state = self .states ["beforeAttributeName" ]
574584 elif data == EOF :
575585 self .tokenQueue .append ({"type" : "ParseError" , "data" :
576586 "expected-end-of-tag-but-got-eof" })
@@ -666,8 +676,14 @@ def afterAttributeValueState(self):
666676 self .emitCurrentToken ()
667677 self .state = self .states ["data" ]
668678 elif data == u"/" :
669- self .processSolidusInTag ()
670- self .state = self .states ["beforeAttributeName" ]
679+ if not self .processSolidusInTag ():
680+ self .state = self .states ["beforeAttributeName" ]
681+ elif data == EOF :
682+ self .tokenQueue .append ({"type" : "ParseError" , "data" :
683+ "unexpected-EOF-after-attribute-value" })
684+ self .emitCurrentToken ()
685+ self .stream .unget (data )
686+ self .state = self .states ["data" ]
671687 else :
672688 self .tokenQueue .append ({"type" : "ParseError" , "data" :
673689 "unexpected-character-after-attribute-value" })
0 commit comments