@@ -114,11 +114,19 @@ def processSolidusInTag(self):
114
114
an EmptyTag
115
115
"""
116
116
117
+ rv = False
118
+
117
119
# We need to consume another character to make sure it's a ">"
118
120
data = self .stream .char ()
119
121
120
122
if self .currentToken ["type" ] == "StartTag" and data == u">" :
121
123
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
122
130
else :
123
131
self .tokenQueue .append ({"type" : "ParseError" , "data" :
124
132
"incorrectly-placed-solidus" })
@@ -127,6 +135,8 @@ def processSolidusInTag(self):
127
135
# doesn't get lost...
128
136
self .stream .unget (data )
129
137
138
+ return rv
139
+
130
140
def consumeNumberEntity (self , isHex ):
131
141
"""This function returns either U+FFFD or the character based on the
132
142
decimal or hexadecimal representation. It also discards ";" if present.
@@ -524,8 +534,8 @@ def attributeNameState(self):
524
534
elif data in spaceCharacters :
525
535
self .state = self .states ["afterAttributeName" ]
526
536
elif data == u"/" :
527
- self .processSolidusInTag ()
528
- self .state = self .states ["beforeAttributeName" ]
537
+ if not self .processSolidusInTag ():
538
+ self .state = self .states ["beforeAttributeName" ]
529
539
elif data == u"'" or data == u'"' :
530
540
self .tokenQueue .append ({"type" : "ParseError" , "data" :
531
541
"invalid-character-in-attribute-name" })
@@ -569,8 +579,8 @@ def afterAttributeNameState(self):
569
579
self .currentToken ["data" ].append ([data , "" ])
570
580
self .state = self .states ["attributeName" ]
571
581
elif data == u"/" :
572
- self .processSolidusInTag ()
573
- self .state = self .states ["beforeAttributeName" ]
582
+ if not self .processSolidusInTag ():
583
+ self .state = self .states ["beforeAttributeName" ]
574
584
elif data == EOF :
575
585
self .tokenQueue .append ({"type" : "ParseError" , "data" :
576
586
"expected-end-of-tag-but-got-eof" })
@@ -666,8 +676,14 @@ def afterAttributeValueState(self):
666
676
self .emitCurrentToken ()
667
677
self .state = self .states ["data" ]
668
678
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" ]
671
687
else :
672
688
self .tokenQueue .append ({"type" : "ParseError" , "data" :
673
689
"unexpected-character-after-attribute-value" })
0 commit comments