@@ -153,25 +153,32 @@ public function parse() {
153
153
the "anything else" entry below. */
154
154
$ state ='characterReferenceData ' ;
155
155
156
- }elseif ($ char ==='- ' ) {
157
- /* If the content model flag is set to either the RCDATA state or
156
+ }elseif (
157
+ $ char ==='- ' &&
158
+ (
159
+ $ this ->content_model ===self ::RCDATA ||
160
+ $ this ->content_model ===self ::CDATA
161
+ ) &&
162
+ $ this ->escape ===false &&
163
+ $ lastFourChars ==='<!-- '
164
+ ) {
165
+ /*
166
+ U+002D HYPHEN-MINUS (-)
167
+ If the content model flag is set to either the RCDATA state or
158
168
the CDATA state, and the escape flag is false, and there are at
159
169
least three characters before this one in the input stream, and the
160
170
last four characters in the input stream, including this one, are
161
171
U+003C LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+002D HYPHEN-MINUS,
162
172
and U+002D HYPHEN-MINUS ("<!--"), then set the escape flag to true. */
163
- if (($ this ->content_model ===self ::RCDATA ||$ this ->content_model ===
164
- self ::CDATA ) &&$ this ->escape ===false &&
165
- $ lastFourChars ==='<!-- ' ) {
166
- $ this ->escape =true ;
167
- }
173
+ $ this ->escape =true ;
168
174
169
175
/* In any case, emit the input character as a character token. Stay
170
176
in the data state. */
171
177
$ this ->emitToken (array (
172
178
'type ' =>self ::CHARACTER ,
173
- 'data ' =>$ char
179
+ 'data ' =>' - '
174
180
));
181
+ // We do the "any case" part as part of "anything else".
175
182
176
183
/* U+003C LESS-THAN SIGN (<) */
177
184
}elseif ($ char ==='< ' &&$ lt_cond ) {
@@ -186,24 +193,29 @@ public function parse() {
186
193
$ state ='tagOpen ' ;
187
194
188
195
/* U+003E GREATER-THAN SIGN (>) */
189
- }elseif ($ char ==='> ' ) {
196
+ }elseif (
197
+ $ char ==='> ' &&
198
+ (
199
+ $ this ->content_model ===self ::RCDATA ||
200
+ $ this ->content_model ===self ::CDATA
201
+ ) &&
202
+ $ this ->escape ===true &&
203
+ substr ($ lastFourChars ,1 ) ==='--> '
204
+ ) {
190
205
/* If the content model flag is set to either the RCDATA state or
191
206
the CDATA state, and the escape flag is true, and the last three
192
207
characters in the input stream including this one are U+002D
193
208
HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN SIGN ("-->"),
194
209
set the escape flag to false. */
195
- if (($ this ->content_model ===self ::RCDATA ||
196
- $ this ->content_model ===self ::CDATA ) &&$ this ->escape ===true &&
197
- substr ($ lastFourChars ,1 ) ==='--> ' ) {
198
- $ this ->escape =false ;
199
- }
210
+ $ this ->escape =false ;
200
211
201
212
/* In any case, emit the input character as a character token.
202
213
Stay in the data state. */
203
214
$ this ->emitToken (array (
204
215
'type ' =>self ::CHARACTER ,
205
- 'data ' =>$ char
216
+ 'data ' =>' > '
206
217
));
218
+ // We do the "any case" part as part of "anything else".
207
219
208
220
}elseif ($ char ===false ) {
209
221
/* EOF
@@ -223,6 +235,7 @@ public function parse() {
223
235
// XSKETCHY: introduced three more fails (at least)
224
236
if ($ char !==' ' &&$ char !=="\n" &&$ char !=="\r" &&
225
237
$ char !=="\t" &&$ char !=="\x0c" ) {
238
+ // XXX: We should only have - and > here when they need to be.
226
239
$ mask ='-> ' .self ::WHITESPACE ;
227
240
if ($ amp_cond )$ mask .='& ' ;
228
241
if ($ lt_cond )$ mask .='< ' ;