@@ -1109,14 +1109,6 @@ public function parse() {
1109
1109
Emit the current tag token. Switch to the data state. */
1110
1110
// not sure if this is the name we want
1111
1111
$ this ->token ['self-closing ' ] = true ;
1112
- /* When an end tag token is emitted with its self-closing flag set,
1113
- that is a parse error. */
1114
- if ($ this ->token ['type ' ] === self ::ENDTAG ) {
1115
- $ this ->emitToken (array (
1116
- 'type ' => self ::PARSEERROR ,
1117
- 'data ' => 'self-closing-end-tag '
1118
- ));
1119
- }
1120
1112
$ this ->emitToken ($ this ->token );
1121
1113
$ state = 'data ' ;
1122
1114
@@ -2367,18 +2359,48 @@ private function characterReferenceInAttributeValue($allowed = false) {
2367
2359
/**
2368
2360
* Emits a token, passing it on to the tree builder.
2369
2361
*/
2370
- protected function emitToken ($ token , $ checkStream = true ) {
2362
+ protected function emitToken ($ token , $ checkStream = true , $ dry = false ) {
2371
2363
if ($ checkStream ) {
2372
2364
// Emit errors from input stream.
2373
2365
while ($ this ->stream ->errors ) {
2374
2366
$ this ->emitToken (array_shift ($ this ->stream ->errors ), false );
2375
2367
}
2376
2368
}
2369
+ if ($ token ['type ' ] === self ::ENDTAG && !empty ($ token ['attr ' ])) {
2370
+ for ($ i = 0 ; $ i < count ($ token ['attr ' ]); $ i ++) {
2371
+ $ this ->emitToken (array (
2372
+ 'type ' => self ::PARSEERROR ,
2373
+ 'data ' => 'attributes-in-end-tag '
2374
+ ));
2375
+ }
2376
+ }
2377
+ if ($ token ['type ' ] === self ::ENDTAG && !empty ($ token ['self-closing ' ])) {
2378
+ $ this ->emitToken (array (
2379
+ 'type ' => self ::PARSEERROR ,
2380
+ 'data ' => 'self-closing-flag-on-end-tag ' ,
2381
+ ));
2382
+ }
2383
+ if ($ token ['type ' ] === self ::STARTTAG ) {
2384
+ // This could be changed to actually pass the tree-builder a hash
2385
+ $ hash = array ();
2386
+ foreach ($ token ['attr ' ] as $ keypair ) {
2387
+ if (isset ($ hash [$ keypair ['name ' ]])) {
2388
+ $ this ->emitToken (array (
2389
+ 'type ' => self ::PARSEERROR ,
2390
+ 'data ' => 'duplicate-attribute ' ,
2391
+ ));
2392
+ } else {
2393
+ $ hash [$ keypair ['name ' ]] = $ keypair ['value ' ];
2394
+ }
2395
+ }
2396
+ }
2377
2397
2378
- // the current structure of attributes is not a terribly good one
2379
- $ this ->tree ->emitToken ($ token );
2398
+ if (!$ dry ) {
2399
+ // the current structure of attributes is not a terribly good one
2400
+ $ this ->tree ->emitToken ($ token );
2401
+ }
2380
2402
2381
- if (is_int ($ this ->tree ->content_model )) {
2403
+
8000
if (! $ dry && is_int ($ this ->tree ->content_model )) {
2382
2404
$ this ->content_model = $ this ->tree ->content_model ;
2383
2405
$ this ->tree ->content_model = null ;
2384
2406
0 commit comments