| 1 |
package Whatpm::HTML; |
package Whatpm::HTML; |
| 2 |
use strict; |
use strict; |
| 3 |
our $VERSION=do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; |
our $VERSION=do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; |
| 4 |
|
use Error qw(:try); |
| 5 |
|
|
| 6 |
## ISSUE: |
## ISSUE: |
| 7 |
## var doc = implementation.createDocument (null, null, null); |
## var doc = implementation.createDocument (null, null, null); |
| 85 |
}; |
}; |
| 86 |
# $phrasing_category: all other elements |
# $phrasing_category: all other elements |
| 87 |
|
|
| 88 |
|
sub parse_byte_string ($$$$;$) { |
| 89 |
|
my $self = ref $_[0] ? shift : shift->new; |
| 90 |
|
my $charset = shift; |
| 91 |
|
my $bytes_s = ref $_[0] ? $_[0] : \($_[0]); |
| 92 |
|
my $s; |
| 93 |
|
|
| 94 |
|
if (defined $charset) { |
| 95 |
|
require Encode; ## TODO: decode(utf8) don't delete BOM |
| 96 |
|
$s = \ (Encode::decode ($charset, $$bytes_s)); |
| 97 |
|
$self->{input_encoding} = lc $charset; ## TODO: normalize name |
| 98 |
|
$self->{confident} = 1; |
| 99 |
|
} else { |
| 100 |
|
## TODO: Implement HTML5 detection algorithm |
| 101 |
|
require Whatpm::Charset::UniversalCharDet; |
| 102 |
|
$charset = Whatpm::Charset::UniversalCharDet->detect_byte_string |
| 103 |
|
(substr ($$bytes_s, 0, 1024)); |
| 104 |
|
$charset ||= 'windows-1252'; |
| 105 |
|
$s = \ (Encode::decode ($charset, $$bytes_s)); |
| 106 |
|
$self->{input_encoding} = $charset; |
| 107 |
|
$self->{confident} = 0; |
| 108 |
|
} |
| 109 |
|
|
| 110 |
|
$self->{change_encoding} = sub { |
| 111 |
|
my $self = shift; |
| 112 |
|
my $charset = lc shift; |
| 113 |
|
## TODO: if $charset is supported |
| 114 |
|
## TODO: normalize charset name |
| 115 |
|
|
| 116 |
|
## "Change the encoding" algorithm: |
| 117 |
|
|
| 118 |
|
## Step 1 |
| 119 |
|
if ($charset eq 'utf-16') { ## ISSUE: UTF-16BE -> UTF-8? UTF-16LE -> UTF-8? |
| 120 |
|
$charset = 'utf-8'; |
| 121 |
|
} |
| 122 |
|
|
| 123 |
|
## Step 2 |
| 124 |
|
if (defined $self->{input_encoding} and |
| 125 |
|
$self->{input_encoding} eq $charset) { |
| 126 |
|
$self->{confident} = 1; |
| 127 |
|
return; |
| 128 |
|
} |
| 129 |
|
|
| 130 |
|
!!!parse-error (type => 'charset label detected:'.$self->{input_encoding}. |
| 131 |
|
':'.$charset, level => 'w'); |
| 132 |
|
|
| 133 |
|
## Step 3 |
| 134 |
|
# if (can) { |
| 135 |
|
## change the encoding on the fly. |
| 136 |
|
#$self->{confident} = 1; |
| 137 |
|
#return; |
| 138 |
|
# } |
| 139 |
|
|
| 140 |
|
## Step 4 |
| 141 |
|
throw Whatpm::HTML::RestartParser (charset => $charset); |
| 142 |
|
}; # $self->{change_encoding} |
| 143 |
|
|
| 144 |
|
my @args = @_; shift @args; # $s |
| 145 |
|
my $return; |
| 146 |
|
try { |
| 147 |
|
$return = $self->parse_char_string ($s, @args); |
| 148 |
|
} catch Whatpm::HTML::RestartParser with { |
| 149 |
|
my $charset = shift->{charset}; |
| 150 |
|
$s = \ (Encode::decode ($charset, $$bytes_s)); |
| 151 |
|
$self->{input_encoding} = $charset; ## TODO: normalize |
| 152 |
|
$self->{confident} = 1; |
| 153 |
|
$return = $self->parse_char_string ($s, @args); |
| 154 |
|
}; |
| 155 |
|
return $return; |
| 156 |
|
} # parse_byte_string |
| 157 |
|
|
| 158 |
|
*parse_char_string = \&parse_string; |
| 159 |
|
|
| 160 |
sub parse_string ($$$;$) { |
sub parse_string ($$$;$) { |
| 161 |
my $self = shift->new; |
my $self = ref $_[0] ? shift : shift->new; |
| 162 |
my $s = \$_[0]; |
my $s = ref $_[0] ? $_[0] : \($_[0]); |
| 163 |
$self->{document} = $_[1]; |
$self->{document} = $_[1]; |
| 164 |
|
@{$self->{document}->child_nodes} = (); |
| 165 |
|
|
| 166 |
## NOTE: |set_inner_html| copies most of this method's code |
## NOTE: |set_inner_html| copies most of this method's code |
| 167 |
|
|
| 168 |
|
$self->{confident} = 1 unless exists $self->{confident}; |
| 169 |
|
$self->{document}->input_encoding ($self->{input_encoding}) |
| 170 |
|
if defined $self->{input_encoding}; |
| 171 |
|
|
| 172 |
my $i = 0; |
my $i = 0; |
| 173 |
my $line = 1; |
my $line = 1; |
| 174 |
my $column = 0; |
my $column = 0; |
| 225 |
$self->{parse_error} = sub { |
$self->{parse_error} = sub { |
| 226 |
# |
# |
| 227 |
}; |
}; |
| 228 |
|
$self->{change_encoding} = sub { |
| 229 |
|
# if ($_[0] is a supported encoding) { |
| 230 |
|
# run "change the encoding" algorithm; |
| 231 |
|
# throw Whatpm::HTML::RestartParser (charset => $new_encoding); |
| 232 |
|
# } |
| 233 |
|
}; |
| 234 |
|
$self->{application_cache_selection} = sub { |
| 235 |
|
# |
| 236 |
|
}; |
| 237 |
return $self; |
return $self; |
| 238 |
} # new |
} # new |
| 239 |
|
|
| 246 |
sub RCDATA_CONTENT_MODEL () { CM_ENTITY | CM_LIMITED_MARKUP } |
sub RCDATA_CONTENT_MODEL () { CM_ENTITY | CM_LIMITED_MARKUP } |
| 247 |
sub PCDATA_CONTENT_MODEL () { CM_ENTITY | CM_FULL_MARKUP } |
sub PCDATA_CONTENT_MODEL () { CM_ENTITY | CM_FULL_MARKUP } |
| 248 |
|
|
| 249 |
|
sub DATA_STATE () { 0 } |
| 250 |
|
sub ENTITY_DATA_STATE () { 1 } |
| 251 |
|
sub TAG_OPEN_STATE () { 2 } |
| 252 |
|
sub CLOSE_TAG_OPEN_STATE () { 3 } |
| 253 |
|
sub TAG_NAME_STATE () { 4 } |
| 254 |
|
sub BEFORE_ATTRIBUTE_NAME_STATE () { 5 } |
| 255 |
|
sub ATTRIBUTE_NAME_STATE () { 6 } |
| 256 |
|
sub AFTER_ATTRIBUTE_NAME_STATE () { 7 } |
| 257 |
|
sub BEFORE_ATTRIBUTE_VALUE_STATE () { 8 } |
| 258 |
|
sub ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE () { 9 } |
| 259 |
|
sub ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE () { 10 } |
| 260 |
|
sub ATTRIBUTE_VALUE_UNQUOTED_STATE () { 11 } |
| 261 |
|
sub ENTITY_IN_ATTRIBUTE_VALUE_STATE () { 12 } |
| 262 |
|
sub MARKUP_DECLARATION_OPEN_STATE () { 13 } |
| 263 |
|
sub COMMENT_START_STATE () { 14 } |
| 264 |
|
sub COMMENT_START_DASH_STATE () { 15 } |
| 265 |
|
sub COMMENT_STATE () { 16 } |
| 266 |
|
sub COMMENT_END_STATE () { 17 } |
| 267 |
|
sub COMMENT_END_DASH_STATE () { 18 } |
| 268 |
|
sub BOGUS_COMMENT_STATE () { 19 } |
| 269 |
|
sub DOCTYPE_STATE () { 20 } |
| 270 |
|
sub BEFORE_DOCTYPE_NAME_STATE () { 21 } |
| 271 |
|
sub DOCTYPE_NAME_STATE () { 22 } |
| 272 |
|
sub AFTER_DOCTYPE_NAME_STATE () { 23 } |
| 273 |
|
sub BEFORE_DOCTYPE_PUBLIC_IDENTIFIER_STATE () { 24 } |
| 274 |
|
sub DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED_STATE () { 25 } |
| 275 |
|
sub DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED_STATE () { 26 } |
| 276 |
|
sub AFTER_DOCTYPE_PUBLIC_IDENTIFIER_STATE () { 27 } |
| 277 |
|
sub BEFORE_DOCTYPE_SYSTEM_IDENTIFIER_STATE () { 28 } |
| 278 |
|
sub DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE () { 29 } |
| 279 |
|
sub DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE () { 30 } |
| 280 |
|
sub AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE () { 31 } |
| 281 |
|
sub BOGUS_DOCTYPE_STATE () { 32 } |
| 282 |
|
|
| 283 |
sub DOCTYPE_TOKEN () { 1 } |
sub DOCTYPE_TOKEN () { 1 } |
| 284 |
sub COMMENT_TOKEN () { 2 } |
sub COMMENT_TOKEN () { 2 } |
| 285 |
sub START_TAG_TOKEN () { 3 } |
sub START_TAG_TOKEN () { 3 } |
| 290 |
sub AFTER_HTML_IMS () { 0b100 } |
sub AFTER_HTML_IMS () { 0b100 } |
| 291 |
sub HEAD_IMS () { 0b1000 } |
sub HEAD_IMS () { 0b1000 } |
| 292 |
sub BODY_IMS () { 0b10000 } |
sub BODY_IMS () { 0b10000 } |
| 293 |
sub BODY_TABLE_IMS () { 0b100000 | BODY_IMS } |
sub BODY_TABLE_IMS () { 0b100000 } |
| 294 |
sub TABLE_IMS () { 0b1000000 } |
sub TABLE_IMS () { 0b1000000 } |
| 295 |
sub ROW_IMS () { 0b10000000 | TABLE_IMS } |
sub ROW_IMS () { 0b10000000 } |
| 296 |
sub BODY_AFTER_IMS () { 0b100000000 } |
sub BODY_AFTER_IMS () { 0b100000000 } |
| 297 |
sub FRAME_IMS () { 0b1000000000 } |
sub FRAME_IMS () { 0b1000000000 } |
| 298 |
|
|
| 303 |
sub AFTER_HEAD_IM () { HEAD_IMS | 0b10 } |
sub AFTER_HEAD_IM () { HEAD_IMS | 0b10 } |
| 304 |
sub BEFORE_HEAD_IM () { HEAD_IMS | 0b11 } |
sub BEFORE_HEAD_IM () { HEAD_IMS | 0b11 } |
| 305 |
sub IN_BODY_IM () { BODY_IMS } |
sub IN_BODY_IM () { BODY_IMS } |
| 306 |
sub IN_CELL_IM () { BODY_TABLE_IMS | 0b01 } |
sub IN_CELL_IM () { BODY_IMS | BODY_TABLE_IMS | 0b01 } |
| 307 |
sub IN_CAPTION_IM () { BODY_TABLE_IMS | 0b10 } |
sub IN_CAPTION_IM () { BODY_IMS | BODY_TABLE_IMS | 0b10 } |
| 308 |
sub IN_ROW_IM () { ROW_IMS | 0b01 } |
sub IN_ROW_IM () { TABLE_IMS | ROW_IMS | 0b01 } |
| 309 |
sub IN_TABLE_BODY_IM () { ROW_IMS | 0b10 } |
sub IN_TABLE_BODY_IM () { TABLE_IMS | ROW_IMS | 0b10 } |
| 310 |
sub IN_TABLE_IM () { TABLE_IMS } |
sub IN_TABLE_IM () { TABLE_IMS } |
| 311 |
sub AFTER_BODY_IM () { BODY_AFTER_IMS } |
sub AFTER_BODY_IM () { BODY_AFTER_IMS } |
| 312 |
sub IN_FRAMESET_IM () { FRAME_IMS | 0b01 } |
sub IN_FRAMESET_IM () { FRAME_IMS | 0b01 } |
| 318 |
|
|
| 319 |
sub _initialize_tokenizer ($) { |
sub _initialize_tokenizer ($) { |
| 320 |
my $self = shift; |
my $self = shift; |
| 321 |
$self->{state} = 'data'; # MUST |
$self->{state} = DATA_STATE; # MUST |
| 322 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # be |
$self->{content_model} = PCDATA_CONTENT_MODEL; # be |
| 323 |
undef $self->{current_token}; # start tag, end tag, comment, or DOCTYPE |
undef $self->{current_token}; # start tag, end tag, comment, or DOCTYPE |
| 324 |
undef $self->{current_attribute}; |
undef $self->{current_attribute}; |
| 340 |
## ->{system_identifier} (DOCTYPE_TOKEN) |
## ->{system_identifier} (DOCTYPE_TOKEN) |
| 341 |
## ->{correct} == 1 or 0 (DOCTYPE_TOKEN) |
## ->{correct} == 1 or 0 (DOCTYPE_TOKEN) |
| 342 |
## ->{attributes} isa HASH (START_TAG_TOKEN, END_TAG_TOKEN) |
## ->{attributes} isa HASH (START_TAG_TOKEN, END_TAG_TOKEN) |
| 343 |
|
## ->{name} |
| 344 |
|
## ->{value} |
| 345 |
|
## ->{has_reference} == 1 or 0 |
| 346 |
## ->{data} (COMMENT_TOKEN, CHARACTER_TOKEN) |
## ->{data} (COMMENT_TOKEN, CHARACTER_TOKEN) |
| 347 |
|
|
| 348 |
## Emitted token MUST immediately be handled by the tree construction state. |
## Emitted token MUST immediately be handled by the tree construction state. |
| 353 |
## has completed loading. If one has, then it MUST be executed |
## has completed loading. If one has, then it MUST be executed |
| 354 |
## and removed from the list. |
## and removed from the list. |
| 355 |
|
|
| 356 |
|
## NOTE: HTML5 "Writing HTML documents" section, applied to |
| 357 |
|
## documents and not to user agents and conformance checkers, |
| 358 |
|
## contains some requirements that are not detected by the |
| 359 |
|
## parsing algorithm: |
| 360 |
|
## - Some requirements on character encoding declarations. ## TODO |
| 361 |
|
## - "Elements MUST NOT contain content that their content model disallows." |
| 362 |
|
## ... Some are parse error, some are not (will be reported by c.c.). |
| 363 |
|
## - Polytheistic slash SHOULD NOT be used. (Applied only to atheists.) ## TODO |
| 364 |
|
## - Text (in elements, attributes, and comments) SHOULD NOT contain |
| 365 |
|
## control characters other than space characters. ## TODO: (what is control character? C0, C1 and DEL? Unicode control character?) |
| 366 |
|
|
| 367 |
|
## TODO: HTML5 poses authors two SHOULD-level requirements that cannot |
| 368 |
|
## be detected by the HTML5 parsing algorithm: |
| 369 |
|
## - Text, |
| 370 |
|
|
| 371 |
sub _get_next_token ($) { |
sub _get_next_token ($) { |
| 372 |
my $self = shift; |
my $self = shift; |
| 373 |
if (@{$self->{token}}) { |
if (@{$self->{token}}) { |
| 375 |
} |
} |
| 376 |
|
|
| 377 |
A: { |
A: { |
| 378 |
if ($self->{state} eq 'data') { |
if ($self->{state} == DATA_STATE) { |
| 379 |
if ($self->{next_input_character} == 0x0026) { # & |
if ($self->{next_input_character} == 0x0026) { # & |
| 380 |
if ($self->{content_model} & CM_ENTITY) { # PCDATA | RCDATA |
if ($self->{content_model} & CM_ENTITY) { # PCDATA | RCDATA |
| 381 |
$self->{state} = 'entity data'; |
$self->{state} = ENTITY_DATA_STATE; |
| 382 |
!!!next-input-character; |
!!!next-input-character; |
| 383 |
redo A; |
redo A; |
| 384 |
} else { |
} else { |
| 400 |
if ($self->{content_model} & CM_FULL_MARKUP or # PCDATA |
if ($self->{content_model} & CM_FULL_MARKUP or # PCDATA |
| 401 |
(($self->{content_model} & CM_LIMITED_MARKUP) and # CDATA | RCDATA |
(($self->{content_model} & CM_LIMITED_MARKUP) and # CDATA | RCDATA |
| 402 |
not $self->{escape})) { |
not $self->{escape})) { |
| 403 |
$self->{state} = 'tag open'; |
$self->{state} = TAG_OPEN_STATE; |
| 404 |
!!!next-input-character; |
!!!next-input-character; |
| 405 |
redo A; |
redo A; |
| 406 |
} else { |
} else { |
| 429 |
!!!emit ($token); |
!!!emit ($token); |
| 430 |
|
|
| 431 |
redo A; |
redo A; |
| 432 |
} elsif ($self->{state} eq 'entity data') { |
} elsif ($self->{state} == ENTITY_DATA_STATE) { |
| 433 |
## (cannot happen in CDATA state) |
## (cannot happen in CDATA state) |
| 434 |
|
|
| 435 |
my $token = $self->_tokenize_attempt_to_consume_an_entity (0); |
my $token = $self->_tokenize_attempt_to_consume_an_entity (0); |
| 436 |
|
|
| 437 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 438 |
# next-input-character is already done |
# next-input-character is already done |
| 439 |
|
|
| 440 |
unless (defined $token) { |
unless (defined $token) { |
| 444 |
} |
} |
| 445 |
|
|
| 446 |
redo A; |
redo A; |
| 447 |
} elsif ($self->{state} eq 'tag open') { |
} elsif ($self->{state} == TAG_OPEN_STATE) { |
| 448 |
if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA |
if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA |
| 449 |
if ($self->{next_input_character} == 0x002F) { # / |
if ($self->{next_input_character} == 0x002F) { # / |
| 450 |
!!!next-input-character; |
!!!next-input-character; |
| 451 |
$self->{state} = 'close tag open'; |
$self->{state} = CLOSE_TAG_OPEN_STATE; |
| 452 |
redo A; |
redo A; |
| 453 |
} else { |
} else { |
| 454 |
## reconsume |
## reconsume |
| 455 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 456 |
|
|
| 457 |
!!!emit ({type => CHARACTER_TOKEN, data => '<'}); |
!!!emit ({type => CHARACTER_TOKEN, data => '<'}); |
| 458 |
|
|
| 460 |
} |
} |
| 461 |
} elsif ($self->{content_model} & CM_FULL_MARKUP) { # PCDATA |
} elsif ($self->{content_model} & CM_FULL_MARKUP) { # PCDATA |
| 462 |
if ($self->{next_input_character} == 0x0021) { # ! |
if ($self->{next_input_character} == 0x0021) { # ! |
| 463 |
$self->{state} = 'markup declaration open'; |
$self->{state} = MARKUP_DECLARATION_OPEN_STATE; |
| 464 |
!!!next-input-character; |
!!!next-input-character; |
| 465 |
redo A; |
redo A; |
| 466 |
} elsif ($self->{next_input_character} == 0x002F) { # / |
} elsif ($self->{next_input_character} == 0x002F) { # / |
| 467 |
$self->{state} = 'close tag open'; |
$self->{state} = CLOSE_TAG_OPEN_STATE; |
| 468 |
!!!next-input-character; |
!!!next-input-character; |
| 469 |
redo A; |
redo A; |
| 470 |
} elsif (0x0041 <= $self->{next_input_character} and |
} elsif (0x0041 <= $self->{next_input_character} and |
| 472 |
$self->{current_token} |
$self->{current_token} |
| 473 |
= {type => START_TAG_TOKEN, |
= {type => START_TAG_TOKEN, |
| 474 |
tag_name => chr ($self->{next_input_character} + 0x0020)}; |
tag_name => chr ($self->{next_input_character} + 0x0020)}; |
| 475 |
$self->{state} = 'tag name'; |
$self->{state} = TAG_NAME_STATE; |
| 476 |
!!!next-input-character; |
!!!next-input-character; |
| 477 |
redo A; |
redo A; |
| 478 |
} elsif (0x0061 <= $self->{next_input_character} and |
} elsif (0x0061 <= $self->{next_input_character} and |
| 479 |
$self->{next_input_character} <= 0x007A) { # a..z |
$self->{next_input_character} <= 0x007A) { # a..z |
| 480 |
$self->{current_token} = {type => START_TAG_TOKEN, |
$self->{current_token} = {type => START_TAG_TOKEN, |
| 481 |
tag_name => chr ($self->{next_input_character})}; |
tag_name => chr ($self->{next_input_character})}; |
| 482 |
$self->{state} = 'tag name'; |
$self->{state} = TAG_NAME_STATE; |
| 483 |
!!!next-input-character; |
!!!next-input-character; |
| 484 |
redo A; |
redo A; |
| 485 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 486 |
!!!parse-error (type => 'empty start tag'); |
!!!parse-error (type => 'empty start tag'); |
| 487 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 488 |
!!!next-input-character; |
!!!next-input-character; |
| 489 |
|
|
| 490 |
!!!emit ({type => CHARACTER_TOKEN, data => '<>'}); |
!!!emit ({type => CHARACTER_TOKEN, data => '<>'}); |
| 492 |
redo A; |
redo A; |
| 493 |
} elsif ($self->{next_input_character} == 0x003F) { # ? |
} elsif ($self->{next_input_character} == 0x003F) { # ? |
| 494 |
!!!parse-error (type => 'pio'); |
!!!parse-error (type => 'pio'); |
| 495 |
$self->{state} = 'bogus comment'; |
$self->{state} = BOGUS_COMMENT_STATE; |
| 496 |
## $self->{next_input_character} is intentionally left as is |
## $self->{next_input_character} is intentionally left as is |
| 497 |
redo A; |
redo A; |
| 498 |
} else { |
} else { |
| 499 |
!!!parse-error (type => 'bare stago'); |
!!!parse-error (type => 'bare stago'); |
| 500 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 501 |
## reconsume |
## reconsume |
| 502 |
|
|
| 503 |
!!!emit ({type => CHARACTER_TOKEN, data => '<'}); |
!!!emit ({type => CHARACTER_TOKEN, data => '<'}); |
| 507 |
} else { |
} else { |
| 508 |
die "$0: $self->{content_model} in tag open"; |
die "$0: $self->{content_model} in tag open"; |
| 509 |
} |
} |
| 510 |
} elsif ($self->{state} eq 'close tag open') { |
} elsif ($self->{state} == CLOSE_TAG_OPEN_STATE) { |
| 511 |
if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA |
if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA |
| 512 |
if (defined $self->{last_emitted_start_tag_name}) { |
if (defined $self->{last_emitted_start_tag_name}) { |
| 513 |
## NOTE: <http://krijnhoetmer.nl/irc-logs/whatwg/20070626#l-564> |
## NOTE: <http://krijnhoetmer.nl/irc-logs/whatwg/20070626#l-564> |
| 522 |
} else { |
} else { |
| 523 |
$self->{next_input_character} = shift @next_char; # reconsume |
$self->{next_input_character} = shift @next_char; # reconsume |
| 524 |
!!!back-next-input-character (@next_char); |
!!!back-next-input-character (@next_char); |
| 525 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 526 |
|
|
| 527 |
!!!emit ({type => CHARACTER_TOKEN, data => '</'}); |
!!!emit ({type => CHARACTER_TOKEN, data => '</'}); |
| 528 |
|
|
| 541 |
$self->{next_input_character} == -1) { |
$self->{next_input_character} == -1) { |
| 542 |
$self->{next_input_character} = shift @next_char; # reconsume |
$self->{next_input_character} = shift @next_char; # reconsume |
| 543 |
!!!back-next-input-character (@next_char); |
!!!back-next-input-character (@next_char); |
| 544 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 545 |
!!!emit ({type => CHARACTER_TOKEN, data => '</'}); |
!!!emit ({type => CHARACTER_TOKEN, data => '</'}); |
| 546 |
redo A; |
redo A; |
| 547 |
} else { |
} else { |
| 552 |
} else { |
} else { |
| 553 |
## No start tag token has ever been emitted |
## No start tag token has ever been emitted |
| 554 |
# next-input-character is already done |
# next-input-character is already done |
| 555 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 556 |
!!!emit ({type => CHARACTER_TOKEN, data => '</'}); |
!!!emit ({type => CHARACTER_TOKEN, data => '</'}); |
| 557 |
redo A; |
redo A; |
| 558 |
} |
} |
| 562 |
$self->{next_input_character} <= 0x005A) { # A..Z |
$self->{next_input_character} <= 0x005A) { # A..Z |
| 563 |
$self->{current_token} = {type => END_TAG_TOKEN, |
$self->{current_token} = {type => END_TAG_TOKEN, |
| 564 |
tag_name => chr ($self->{next_input_character} + 0x0020)}; |
tag_name => chr ($self->{next_input_character} + 0x0020)}; |
| 565 |
$self->{state} = 'tag name'; |
$self->{state} = TAG_NAME_STATE; |
| 566 |
!!!next-input-character; |
!!!next-input-character; |
| 567 |
redo A; |
redo A; |
| 568 |
} elsif (0x0061 <= $self->{next_input_character} and |
} elsif (0x0061 <= $self->{next_input_character} and |
| 569 |
$self->{next_input_character} <= 0x007A) { # a..z |
$self->{next_input_character} <= 0x007A) { # a..z |
| 570 |
$self->{current_token} = {type => END_TAG_TOKEN, |
$self->{current_token} = {type => END_TAG_TOKEN, |
| 571 |
tag_name => chr ($self->{next_input_character})}; |
tag_name => chr ($self->{next_input_character})}; |
| 572 |
$self->{state} = 'tag name'; |
$self->{state} = TAG_NAME_STATE; |
| 573 |
!!!next-input-character; |
!!!next-input-character; |
| 574 |
redo A; |
redo A; |
| 575 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 576 |
!!!parse-error (type => 'empty end tag'); |
!!!parse-error (type => 'empty end tag'); |
| 577 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 578 |
!!!next-input-character; |
!!!next-input-character; |
| 579 |
redo A; |
redo A; |
| 580 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 581 |
!!!parse-error (type => 'bare etago'); |
!!!parse-error (type => 'bare etago'); |
| 582 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 583 |
# reconsume |
# reconsume |
| 584 |
|
|
| 585 |
!!!emit ({type => CHARACTER_TOKEN, data => '</'}); |
!!!emit ({type => CHARACTER_TOKEN, data => '</'}); |
| 587 |
redo A; |
redo A; |
| 588 |
} else { |
} else { |
| 589 |
!!!parse-error (type => 'bogus end tag'); |
!!!parse-error (type => 'bogus end tag'); |
| 590 |
$self->{state} = 'bogus comment'; |
$self->{state} = BOGUS_COMMENT_STATE; |
| 591 |
## $self->{next_input_character} is intentionally left as is |
## $self->{next_input_character} is intentionally left as is |
| 592 |
redo A; |
redo A; |
| 593 |
} |
} |
| 594 |
} elsif ($self->{state} eq 'tag name') { |
} elsif ($self->{state} == TAG_NAME_STATE) { |
| 595 |
if ($self->{next_input_character} == 0x0009 or # HT |
if ($self->{next_input_character} == 0x0009 or # HT |
| 596 |
$self->{next_input_character} == 0x000A or # LF |
$self->{next_input_character} == 0x000A or # LF |
| 597 |
$self->{next_input_character} == 0x000B or # VT |
$self->{next_input_character} == 0x000B or # VT |
| 598 |
$self->{next_input_character} == 0x000C or # FF |
$self->{next_input_character} == 0x000C or # FF |
| 599 |
$self->{next_input_character} == 0x0020) { # SP |
$self->{next_input_character} == 0x0020) { # SP |
| 600 |
$self->{state} = 'before attribute name'; |
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
| 601 |
!!!next-input-character; |
!!!next-input-character; |
| 602 |
redo A; |
redo A; |
| 603 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 613 |
} else { |
} else { |
| 614 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 615 |
} |
} |
| 616 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 617 |
!!!next-input-character; |
!!!next-input-character; |
| 618 |
|
|
| 619 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 640 |
} else { |
} else { |
| 641 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 642 |
} |
} |
| 643 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 644 |
# reconsume |
# reconsume |
| 645 |
|
|
| 646 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 656 |
} else { |
} else { |
| 657 |
!!!parse-error (type => 'nestc'); |
!!!parse-error (type => 'nestc'); |
| 658 |
} |
} |
| 659 |
$self->{state} = 'before attribute name'; |
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
| 660 |
# next-input-character is already done |
# next-input-character is already done |
| 661 |
redo A; |
redo A; |
| 662 |
} else { |
} else { |
| 666 |
!!!next-input-character; |
!!!next-input-character; |
| 667 |
redo A; |
redo A; |
| 668 |
} |
} |
| 669 |
} elsif ($self->{state} eq 'before attribute name') { |
} elsif ($self->{state} == BEFORE_ATTRIBUTE_NAME_STATE) { |
| 670 |
if ($self->{next_input_character} == 0x0009 or # HT |
if ($self->{next_input_character} == 0x0009 or # HT |
| 671 |
$self->{next_input_character} == 0x000A or # LF |
$self->{next_input_character} == 0x000A or # LF |
| 672 |
$self->{next_input_character} == 0x000B or # VT |
$self->{next_input_character} == 0x000B or # VT |
| 688 |
} else { |
} else { |
| 689 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 690 |
} |
} |
| 691 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 692 |
!!!next-input-character; |
!!!next-input-character; |
| 693 |
|
|
| 694 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 698 |
$self->{next_input_character} <= 0x005A) { # A..Z |
$self->{next_input_character} <= 0x005A) { # A..Z |
| 699 |
$self->{current_attribute} = {name => chr ($self->{next_input_character} + 0x0020), |
$self->{current_attribute} = {name => chr ($self->{next_input_character} + 0x0020), |
| 700 |
value => ''}; |
value => ''}; |
| 701 |
$self->{state} = 'attribute name'; |
$self->{state} = ATTRIBUTE_NAME_STATE; |
| 702 |
!!!next-input-character; |
!!!next-input-character; |
| 703 |
redo A; |
redo A; |
| 704 |
} elsif ($self->{next_input_character} == 0x002F) { # / |
} elsif ($self->{next_input_character} == 0x002F) { # / |
| 728 |
} else { |
} else { |
| 729 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 730 |
} |
} |
| 731 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 732 |
# reconsume |
# reconsume |
| 733 |
|
|
| 734 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 737 |
} else { |
} else { |
| 738 |
$self->{current_attribute} = {name => chr ($self->{next_input_character}), |
$self->{current_attribute} = {name => chr ($self->{next_input_character}), |
| 739 |
value => ''}; |
value => ''}; |
| 740 |
$self->{state} = 'attribute name'; |
$self->{state} = ATTRIBUTE_NAME_STATE; |
| 741 |
!!!next-input-character; |
!!!next-input-character; |
| 742 |
redo A; |
redo A; |
| 743 |
} |
} |
| 744 |
} elsif ($self->{state} eq 'attribute name') { |
} elsif ($self->{state} == ATTRIBUTE_NAME_STATE) { |
| 745 |
my $before_leave = sub { |
my $before_leave = sub { |
| 746 |
if (exists $self->{current_token}->{attributes} # start tag or end tag |
if (exists $self->{current_token}->{attributes} # start tag or end tag |
| 747 |
->{$self->{current_attribute}->{name}}) { # MUST |
->{$self->{current_attribute}->{name}}) { # MUST |
| 759 |
$self->{next_input_character} == 0x000C or # FF |
$self->{next_input_character} == 0x000C or # FF |
| 760 |
$self->{next_input_character} == 0x0020) { # SP |
$self->{next_input_character} == 0x0020) { # SP |
| 761 |
$before_leave->(); |
$before_leave->(); |
| 762 |
$self->{state} = 'after attribute name'; |
$self->{state} = AFTER_ATTRIBUTE_NAME_STATE; |
| 763 |
!!!next-input-character; |
!!!next-input-character; |
| 764 |
redo A; |
redo A; |
| 765 |
} elsif ($self->{next_input_character} == 0x003D) { # = |
} elsif ($self->{next_input_character} == 0x003D) { # = |
| 766 |
$before_leave->(); |
$before_leave->(); |
| 767 |
$self->{state} = 'before attribute value'; |
$self->{state} = BEFORE_ATTRIBUTE_VALUE_STATE; |
| 768 |
!!!next-input-character; |
!!!next-input-character; |
| 769 |
redo A; |
redo A; |
| 770 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 781 |
} else { |
} else { |
| 782 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 783 |
} |
} |
| 784 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 785 |
!!!next-input-character; |
!!!next-input-character; |
| 786 |
|
|
| 787 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 804 |
} else { |
} else { |
| 805 |
!!!parse-error (type => 'nestc'); |
!!!parse-error (type => 'nestc'); |
| 806 |
} |
} |
| 807 |
$self->{state} = 'before attribute name'; |
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
| 808 |
# next-input-character is already done |
# next-input-character is already done |
| 809 |
redo A; |
redo A; |
| 810 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 822 |
} else { |
} else { |
| 823 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 824 |
} |
} |
| 825 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 826 |
# reconsume |
# reconsume |
| 827 |
|
|
| 828 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 834 |
!!!next-input-character; |
!!!next-input-character; |
| 835 |
redo A; |
redo A; |
| 836 |
} |
} |
| 837 |
} elsif ($self->{state} eq 'after attribute name') { |
} elsif ($self->{state} == AFTER_ATTRIBUTE_NAME_STATE) { |
| 838 |
if ($self->{next_input_character} == 0x0009 or # HT |
if ($self->{next_input_character} == 0x0009 or # HT |
| 839 |
$self->{next_input_character} == 0x000A or # LF |
$self->{next_input_character} == 0x000A or # LF |
| 840 |
$self->{next_input_character} == 0x000B or # VT |
$self->{next_input_character} == 0x000B or # VT |
| 844 |
!!!next-input-character; |
!!!next-input-character; |
| 845 |
redo A; |
redo A; |
| 846 |
} elsif ($self->{next_input_character} == 0x003D) { # = |
} elsif ($self->{next_input_character} == 0x003D) { # = |
| 847 |
$self->{state} = 'before attribute value'; |
$self->{state} = BEFORE_ATTRIBUTE_VALUE_STATE; |
| 848 |
!!!next-input-character; |
!!!next-input-character; |
| 849 |
redo A; |
redo A; |
| 850 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 860 |
} else { |
} else { |
| 861 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 862 |
} |
} |
| 863 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 864 |
!!!next-input-character; |
!!!next-input-character; |
| 865 |
|
|
| 866 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 870 |
$self->{next_input_character} <= 0x005A) { # A..Z |
$self->{next_input_character} <= 0x005A) { # A..Z |
| 871 |
$self->{current_attribute} = {name => chr ($self->{next_input_character} + 0x0020), |
$self->{current_attribute} = {name => chr ($self->{next_input_character} + 0x0020), |
| 872 |
value => ''}; |
value => ''}; |
| 873 |
$self->{state} = 'attribute name'; |
$self->{state} = ATTRIBUTE_NAME_STATE; |
| 874 |
!!!next-input-character; |
!!!next-input-character; |
| 875 |
redo A; |
redo A; |
| 876 |
} elsif ($self->{next_input_character} == 0x002F) { # / |
} elsif ($self->{next_input_character} == 0x002F) { # / |
| 884 |
!!!parse-error (type => 'nestc'); |
!!!parse-error (type => 'nestc'); |
| 885 |
## TODO: Different error type for <aa / bb> than <aa/> |
## TODO: Different error type for <aa / bb> than <aa/> |
| 886 |
} |
} |
| 887 |
$self->{state} = 'before attribute name'; |
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
| 888 |
# next-input-character is already done |
# next-input-character is already done |
| 889 |
redo A; |
redo A; |
| 890 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 901 |
} else { |
} else { |
| 902 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 903 |
} |
} |
| 904 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 905 |
# reconsume |
# reconsume |
| 906 |
|
|
| 907 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 910 |
} else { |
} else { |
| 911 |
$self->{current_attribute} = {name => chr ($self->{next_input_character}), |
$self->{current_attribute} = {name => chr ($self->{next_input_character}), |
| 912 |
value => ''}; |
value => ''}; |
| 913 |
$self->{state} = 'attribute name'; |
$self->{state} = ATTRIBUTE_NAME_STATE; |
| 914 |
!!!next-input-character; |
!!!next-input-character; |
| 915 |
redo A; |
redo A; |
| 916 |
} |
} |
| 917 |
} elsif ($self->{state} eq 'before attribute value') { |
} elsif ($self->{state} == BEFORE_ATTRIBUTE_VALUE_STATE) { |
| 918 |
if ($self->{next_input_character} == 0x0009 or # HT |
if ($self->{next_input_character} == 0x0009 or # HT |
| 919 |
$self->{next_input_character} == 0x000A or # LF |
$self->{next_input_character} == 0x000A or # LF |
| 920 |
$self->{next_input_character} == 0x000B or # VT |
$self->{next_input_character} == 0x000B or # VT |
| 924 |
!!!next-input-character; |
!!!next-input-character; |
| 925 |
redo A; |
redo A; |
| 926 |
} elsif ($self->{next_input_character} == 0x0022) { # " |
} elsif ($self->{next_input_character} == 0x0022) { # " |
| 927 |
$self->{state} = 'attribute value (double-quoted)'; |
$self->{state} = ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE; |
| 928 |
!!!next-input-character; |
!!!next-input-character; |
| 929 |
redo A; |
redo A; |
| 930 |
} elsif ($self->{next_input_character} == 0x0026) { # & |
} elsif ($self->{next_input_character} == 0x0026) { # & |
| 931 |
$self->{state} = 'attribute value (unquoted)'; |
$self->{state} = ATTRIBUTE_VALUE_UNQUOTED_STATE; |
| 932 |
## reconsume |
## reconsume |
| 933 |
redo A; |
redo A; |
| 934 |
} elsif ($self->{next_input_character} == 0x0027) { # ' |
} elsif ($self->{next_input_character} == 0x0027) { # ' |
| 935 |
$self->{state} = 'attribute value (single-quoted)'; |
$self->{state} = ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE; |
| 936 |
!!!next-input-character; |
!!!next-input-character; |
| 937 |
redo A; |
redo A; |
| 938 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 948 |
} else { |
} else { |
| 949 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 950 |
} |
} |
| 951 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 952 |
!!!next-input-character; |
!!!next-input-character; |
| 953 |
|
|
| 954 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 968 |
} else { |
} else { |
| 969 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 970 |
} |
} |
| 971 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 972 |
## reconsume |
## reconsume |
| 973 |
|
|
| 974 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 976 |
redo A; |
redo A; |
| 977 |
} else { |
} else { |
| 978 |
$self->{current_attribute}->{value} .= chr ($self->{next_input_character}); |
$self->{current_attribute}->{value} .= chr ($self->{next_input_character}); |
| 979 |
$self->{state} = 'attribute value (unquoted)'; |
$self->{state} = ATTRIBUTE_VALUE_UNQUOTED_STATE; |
| 980 |
!!!next-input-character; |
!!!next-input-character; |
| 981 |
redo A; |
redo A; |
| 982 |
} |
} |
| 983 |
} elsif ($self->{state} eq 'attribute value (double-quoted)') { |
} elsif ($self->{state} == ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE) { |
| 984 |
if ($self->{next_input_character} == 0x0022) { # " |
if ($self->{next_input_character} == 0x0022) { # " |
| 985 |
$self->{state} = 'before attribute name'; |
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
| 986 |
!!!next-input-character; |
!!!next-input-character; |
| 987 |
redo A; |
redo A; |
| 988 |
} elsif ($self->{next_input_character} == 0x0026) { # & |
} elsif ($self->{next_input_character} == 0x0026) { # & |
| 989 |
$self->{last_attribute_value_state} = 'attribute value (double-quoted)'; |
$self->{last_attribute_value_state} = $self->{state}; |
| 990 |
$self->{state} = 'entity in attribute value'; |
$self->{state} = ENTITY_IN_ATTRIBUTE_VALUE_STATE; |
| 991 |
!!!next-input-character; |
!!!next-input-character; |
| 992 |
redo A; |
redo A; |
| 993 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1004 |
} else { |
} else { |
| 1005 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 1006 |
} |
} |
| 1007 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1008 |
## reconsume |
## reconsume |
| 1009 |
|
|
| 1010 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 1016 |
!!!next-input-character; |
!!!next-input-character; |
| 1017 |
redo A; |
redo A; |
| 1018 |
} |
} |
| 1019 |
} elsif ($self->{state} eq 'attribute value (single-quoted)') { |
} elsif ($self->{state} == ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE) { |
| 1020 |
if ($self->{next_input_character} == 0x0027) { # ' |
if ($self->{next_input_character} == 0x0027) { # ' |
| 1021 |
$self->{state} = 'before attribute name'; |
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
| 1022 |
!!!next-input-character; |
!!!next-input-character; |
| 1023 |
redo A; |
redo A; |
| 1024 |
} elsif ($self->{next_input_character} == 0x0026) { # & |
} elsif ($self->{next_input_character} == 0x0026) { # & |
| 1025 |
$self->{last_attribute_value_state} = 'attribute value (single-quoted)'; |
$self->{last_attribute_value_state} = $self->{state}; |
| 1026 |
$self->{state} = 'entity in attribute value'; |
$self->{state} = ENTITY_IN_ATTRIBUTE_VALUE_STATE; |
| 1027 |
!!!next-input-character; |
!!!next-input-character; |
| 1028 |
redo A; |
redo A; |
| 1029 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1040 |
} else { |
} else { |
| 1041 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 1042 |
} |
} |
| 1043 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1044 |
## reconsume |
## reconsume |
| 1045 |
|
|
| 1046 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 1052 |
!!!next-input-character; |
!!!next-input-character; |
| 1053 |
redo A; |
redo A; |
| 1054 |
} |
} |
| 1055 |
} elsif ($self->{state} eq 'attribute value (unquoted)') { |
} elsif ($self->{state} == ATTRIBUTE_VALUE_UNQUOTED_STATE) { |
| 1056 |
if ($self->{next_input_character} == 0x0009 or # HT |
if ($self->{next_input_character} == 0x0009 or # HT |
| 1057 |
$self->{next_input_character} == 0x000A or # LF |
$self->{next_input_character} == 0x000A or # LF |
| 1058 |
$self->{next_input_character} == 0x000B or # HT |
$self->{next_input_character} == 0x000B or # HT |
| 1059 |
$self->{next_input_character} == 0x000C or # FF |
$self->{next_input_character} == 0x000C or # FF |
| 1060 |
$self->{next_input_character} == 0x0020) { # SP |
$self->{next_input_character} == 0x0020) { # SP |
| 1061 |
$self->{state} = 'before attribute name'; |
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
| 1062 |
!!!next-input-character; |
!!!next-input-character; |
| 1063 |
redo A; |
redo A; |
| 1064 |
} elsif ($self->{next_input_character} == 0x0026) { # & |
} elsif ($self->{next_input_character} == 0x0026) { # & |
| 1065 |
$self->{last_attribute_value_state} = 'attribute value (unquoted)'; |
$self->{last_attribute_value_state} = $self->{state}; |
| 1066 |
$self->{state} = 'entity in attribute value'; |
$self->{state} = ENTITY_IN_ATTRIBUTE_VALUE_STATE; |
| 1067 |
!!!next-input-character; |
!!!next-input-character; |
| 1068 |
redo A; |
redo A; |
| 1069 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 1079 |
} else { |
} else { |
| 1080 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 1081 |
} |
} |
| 1082 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1083 |
!!!next-input-character; |
!!!next-input-character; |
| 1084 |
|
|
| 1085 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 1099 |
} else { |
} else { |
| 1100 |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
die "$0: $self->{current_token}->{type}: Unknown token type"; |
| 1101 |
} |
} |
| 1102 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1103 |
## reconsume |
## reconsume |
| 1104 |
|
|
| 1105 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
| 1111 |
!!!next-input-character; |
!!!next-input-character; |
| 1112 |
redo A; |
redo A; |
| 1113 |
} |
} |
| 1114 |
} elsif ($self->{state} eq 'entity in attribute value') { |
} elsif ($self->{state} == ENTITY_IN_ATTRIBUTE_VALUE_STATE) { |
| 1115 |
my $token = $self->_tokenize_attempt_to_consume_an_entity (1); |
my $token = $self->_tokenize_attempt_to_consume_an_entity (1); |
| 1116 |
|
|
| 1117 |
unless (defined $token) { |
unless (defined $token) { |
| 1118 |
$self->{current_attribute}->{value} .= '&'; |
$self->{current_attribute}->{value} .= '&'; |
| 1119 |
} else { |
} else { |
| 1120 |
$self->{current_attribute}->{value} .= $token->{data}; |
$self->{current_attribute}->{value} .= $token->{data}; |
| 1121 |
|
$self->{current_attribute}->{has_reference} = $token->{has_reference}; |
| 1122 |
## ISSUE: spec says "append the returned character token to the current attribute's value" |
## ISSUE: spec says "append the returned character token to the current attribute's value" |
| 1123 |
} |
} |
| 1124 |
|
|
| 1125 |
$self->{state} = $self->{last_attribute_value_state}; |
$self->{state} = $self->{last_attribute_value_state}; |
| 1126 |
# next-input-character is already done |
# next-input-character is already done |
| 1127 |
redo A; |
redo A; |
| 1128 |
} elsif ($self->{state} eq 'bogus comment') { |
} elsif ($self->{state} == BOGUS_COMMENT_STATE) { |
| 1129 |
## (only happen if PCDATA state) |
## (only happen if PCDATA state) |
| 1130 |
|
|
| 1131 |
my $token = {type => COMMENT_TOKEN, data => ''}; |
my $token = {type => COMMENT_TOKEN, data => ''}; |
| 1132 |
|
|
| 1133 |
BC: { |
BC: { |
| 1134 |
if ($self->{next_input_character} == 0x003E) { # > |
if ($self->{next_input_character} == 0x003E) { # > |
| 1135 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1136 |
!!!next-input-character; |
!!!next-input-character; |
| 1137 |
|
|
| 1138 |
!!!emit ($token); |
!!!emit ($token); |
| 1139 |
|
|
| 1140 |
redo A; |
redo A; |
| 1141 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1142 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1143 |
## reconsume |
## reconsume |
| 1144 |
|
|
| 1145 |
!!!emit ($token); |
!!!emit ($token); |
| 1151 |
redo BC; |
redo BC; |
| 1152 |
} |
} |
| 1153 |
} # BC |
} # BC |
| 1154 |
} elsif ($self->{state} eq 'markup declaration open') { |
} elsif ($self->{state} == MARKUP_DECLARATION_OPEN_STATE) { |
| 1155 |
## (only happen if PCDATA state) |
## (only happen if PCDATA state) |
| 1156 |
|
|
| 1157 |
my @next_char; |
my @next_char; |
| 1162 |
push @next_char, $self->{next_input_character}; |
push @next_char, $self->{next_input_character}; |
| 1163 |
if ($self->{next_input_character} == 0x002D) { # - |
if ($self->{next_input_character} == 0x002D) { # - |
| 1164 |
$self->{current_token} = {type => COMMENT_TOKEN, data => ''}; |
$self->{current_token} = {type => COMMENT_TOKEN, data => ''}; |
| 1165 |
$self->{state} = 'comment start'; |
$self->{state} = COMMENT_START_STATE; |
| 1166 |
!!!next-input-character; |
!!!next-input-character; |
| 1167 |
redo A; |
redo A; |
| 1168 |
} |
} |
| 1193 |
if ($self->{next_input_character} == 0x0045 or # E |
if ($self->{next_input_character} == 0x0045 or # E |
| 1194 |
$self->{next_input_character} == 0x0065) { # e |
$self->{next_input_character} == 0x0065) { # e |
| 1195 |
## ISSUE: What a stupid code this is! |
## ISSUE: What a stupid code this is! |
| 1196 |
$self->{state} = 'DOCTYPE'; |
$self->{state} = DOCTYPE_STATE; |
| 1197 |
!!!next-input-character; |
!!!next-input-character; |
| 1198 |
redo A; |
redo A; |
| 1199 |
} |
} |
| 1207 |
!!!parse-error (type => 'bogus comment'); |
!!!parse-error (type => 'bogus comment'); |
| 1208 |
$self->{next_input_character} = shift @next_char; |
$self->{next_input_character} = shift @next_char; |
| 1209 |
!!!back-next-input-character (@next_char); |
!!!back-next-input-character (@next_char); |
| 1210 |
$self->{state} = 'bogus comment'; |
$self->{state} = BOGUS_COMMENT_STATE; |
| 1211 |
redo A; |
redo A; |
| 1212 |
|
|
| 1213 |
## ISSUE: typos in spec: chacacters, is is a parse error |
## ISSUE: typos in spec: chacacters, is is a parse error |
| 1214 |
## ISSUE: spec is somewhat unclear on "is the first character that will be in the comment"; what is "that will be in the comment" is what the algorithm defines, isn't it? |
## ISSUE: spec is somewhat unclear on "is the first character that will be in the comment"; what is "that will be in the comment" is what the algorithm defines, isn't it? |
| 1215 |
} elsif ($self->{state} eq 'comment start') { |
} elsif ($self->{state} == COMMENT_START_STATE) { |
| 1216 |
if ($self->{next_input_character} == 0x002D) { # - |
if ($self->{next_input_character} == 0x002D) { # - |
| 1217 |
$self->{state} = 'comment start dash'; |
$self->{state} = COMMENT_START_DASH_STATE; |
| 1218 |
!!!next-input-character; |
!!!next-input-character; |
| 1219 |
redo A; |
redo A; |
| 1220 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 1221 |
!!!parse-error (type => 'bogus comment'); |
!!!parse-error (type => 'bogus comment'); |
| 1222 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1223 |
!!!next-input-character; |
!!!next-input-character; |
| 1224 |
|
|
| 1225 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{current_token}); # comment |
| 1227 |
redo A; |
redo A; |
| 1228 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1229 |
!!!parse-error (type => 'unclosed comment'); |
!!!parse-error (type => 'unclosed comment'); |
| 1230 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1231 |
## reconsume |
## reconsume |
| 1232 |
|
|
| 1233 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{current_token}); # comment |
| 1236 |
} else { |
} else { |
| 1237 |
$self->{current_token}->{data} # comment |
$self->{current_token}->{data} # comment |
| 1238 |
.= chr ($self->{next_input_character}); |
.= chr ($self->{next_input_character}); |
| 1239 |
$self->{state} = 'comment'; |
$self->{state} = COMMENT_STATE; |
| 1240 |
!!!next-input-character; |
!!!next-input-character; |
| 1241 |
redo A; |
redo A; |
| 1242 |
} |
} |
| 1243 |
} elsif ($self->{state} eq 'comment start dash') { |
} elsif ($self->{state} == COMMENT_START_DASH_STATE) { |
| 1244 |
if ($self->{next_input_character} == 0x002D) { # - |
if ($self->{next_input_character} == 0x002D) { # - |
| 1245 |
$self->{state} = 'comment end'; |
$self->{state} = COMMENT_END_STATE; |
| 1246 |
!!!next-input-character; |
!!!next-input-character; |
| 1247 |
redo A; |
redo A; |
| 1248 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 1249 |
!!!parse-error (type => 'bogus comment'); |
!!!parse-error (type => 'bogus comment'); |
| 1250 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1251 |
!!!next-input-character; |
!!!next-input-character; |
| 1252 |
|
|
| 1253 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{current_token}); # comment |
| 1255 |
redo A; |
redo A; |
| 1256 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1257 |
!!!parse-error (type => 'unclosed comment'); |
!!!parse-error (type => 'unclosed comment'); |
| 1258 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1259 |
## reconsume |
## reconsume |
| 1260 |
|
|
| 1261 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{current_token}); # comment |
| 1264 |
} else { |
} else { |
| 1265 |
$self->{current_token}->{data} # comment |
$self->{current_token}->{data} # comment |
| 1266 |
.= '-' . chr ($self->{next_input_character}); |
.= '-' . chr ($self->{next_input_character}); |
| 1267 |
$self->{state} = 'comment'; |
$self->{state} = COMMENT_STATE; |
| 1268 |
!!!next-input-character; |
!!!next-input-character; |
| 1269 |
redo A; |
redo A; |
| 1270 |
} |
} |
| 1271 |
} elsif ($self->{state} eq 'comment') { |
} elsif ($self->{state} == COMMENT_STATE) { |
| 1272 |
if ($self->{next_input_character} == 0x002D) { # - |
if ($self->{next_input_character} == 0x002D) { # - |
| 1273 |
$self->{state} = 'comment end dash'; |
$self->{state} = COMMENT_END_DASH_STATE; |
| 1274 |
!!!next-input-character; |
!!!next-input-character; |
| 1275 |
redo A; |
redo A; |
| 1276 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1277 |
!!!parse-error (type => 'unclosed comment'); |
!!!parse-error (type => 'unclosed comment'); |
| 1278 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1279 |
## reconsume |
## reconsume |
| 1280 |
|
|
| 1281 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{current_token}); # comment |
| 1287 |
!!!next-input-character; |
!!!next-input-character; |
| 1288 |
redo A; |
redo A; |
| 1289 |
} |
} |
| 1290 |
} elsif ($self->{state} eq 'comment end dash') { |
} elsif ($self->{state} == COMMENT_END_DASH_STATE) { |
| 1291 |
if ($self->{next_input_character} == 0x002D) { # - |
if ($self->{next_input_character} == 0x002D) { # - |
| 1292 |
$self->{state} = 'comment end'; |
$self->{state} = COMMENT_END_STATE; |
| 1293 |
!!!next-input-character; |
!!!next-input-character; |
| 1294 |
redo A; |
redo A; |
| 1295 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1296 |
!!!parse-error (type => 'unclosed comment'); |
!!!parse-error (type => 'unclosed comment'); |
| 1297 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1298 |
## reconsume |
## reconsume |
| 1299 |
|
|
| 1300 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{current_token}); # comment |
| 1302 |
redo A; |
redo A; |
| 1303 |
} else { |
} else { |
| 1304 |
$self->{current_token}->{data} .= '-' . chr ($self->{next_input_character}); # comment |
$self->{current_token}->{data} .= '-' . chr ($self->{next_input_character}); # comment |
| 1305 |
$self->{state} = 'comment'; |
$self->{state} = COMMENT_STATE; |
| 1306 |
!!!next-input-character; |
!!!next-input-character; |
| 1307 |
redo A; |
redo A; |
| 1308 |
} |
} |
| 1309 |
} elsif ($self->{state} eq 'comment end') { |
} elsif ($self->{state} == COMMENT_END_STATE) { |
| 1310 |
if ($self->{next_input_character} == 0x003E) { # > |
if ($self->{next_input_character} == 0x003E) { # > |
| 1311 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1312 |
!!!next-input-character; |
!!!next-input-character; |
| 1313 |
|
|
| 1314 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{current_token}); # comment |
| 1322 |
redo A; |
redo A; |
| 1323 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1324 |
!!!parse-error (type => 'unclosed comment'); |
!!!parse-error (type => 'unclosed comment'); |
| 1325 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1326 |
## reconsume |
## reconsume |
| 1327 |
|
|
| 1328 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{current_token}); # comment |
| 1331 |
} else { |
} else { |
| 1332 |
!!!parse-error (type => 'dash in comment'); |
!!!parse-error (type => 'dash in comment'); |
| 1333 |
$self->{current_token}->{data} .= '--' . chr ($self->{next_input_character}); # comment |
$self->{current_token}->{data} .= '--' . chr ($self->{next_input_character}); # comment |
| 1334 |
$self->{state} = 'comment'; |
$self->{state} = COMMENT_STATE; |
| 1335 |
!!!next-input-character; |
!!!next-input-character; |
| 1336 |
redo A; |
redo A; |
| 1337 |
} |
} |
| 1338 |
} elsif ($self->{state} eq 'DOCTYPE') { |
} elsif ($self->{state} == DOCTYPE_STATE) { |
| 1339 |
if ($self->{next_input_character} == 0x0009 or # HT |
if ($self->{next_input_character} == 0x0009 or # HT |
| 1340 |
$self->{next_input_character} == 0x000A or # LF |
$self->{next_input_character} == 0x000A or # LF |
| 1341 |
$self->{next_input_character} == 0x000B or # VT |
$self->{next_input_character} == 0x000B or # VT |
| 1342 |
$self->{next_input_character} == 0x000C or # FF |
$self->{next_input_character} == 0x000C or # FF |
| 1343 |
$self->{next_input_character} == 0x0020) { # SP |
$self->{next_input_character} == 0x0020) { # SP |
| 1344 |
$self->{state} = 'before DOCTYPE name'; |
$self->{state} = BEFORE_DOCTYPE_NAME_STATE; |
| 1345 |
!!!next-input-character; |
!!!next-input-character; |
| 1346 |
redo A; |
redo A; |
| 1347 |
} else { |
} else { |
| 1348 |
!!!parse-error (type => 'no space before DOCTYPE name'); |
!!!parse-error (type => 'no space before DOCTYPE name'); |
| 1349 |
$self->{state} = 'before DOCTYPE name'; |
$self->{state} = BEFORE_DOCTYPE_NAME_STATE; |
| 1350 |
## reconsume |
## reconsume |
| 1351 |
redo A; |
redo A; |
| 1352 |
} |
} |
| 1353 |
} elsif ($self->{state} eq 'before DOCTYPE name') { |
} elsif ($self->{state} == BEFORE_DOCTYPE_NAME_STATE) { |
| 1354 |
if ($self->{next_input_character} == 0x0009 or # HT |
if ($self->{next_input_character} == 0x0009 or # HT |
| 1355 |
$self->{next_input_character} == 0x000A or # LF |
$self->{next_input_character} == 0x000A or # LF |
| 1356 |
$self->{next_input_character} == 0x000B or # VT |
$self->{next_input_character} == 0x000B or # VT |
| 1361 |
redo A; |
redo A; |
| 1362 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 1363 |
!!!parse-error (type => 'no DOCTYPE name'); |
!!!parse-error (type => 'no DOCTYPE name'); |
| 1364 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1365 |
!!!next-input-character; |
!!!next-input-character; |
| 1366 |
|
|
| 1367 |
!!!emit ({type => DOCTYPE_TOKEN}); # incorrect |
!!!emit ({type => DOCTYPE_TOKEN}); # incorrect |
| 1369 |
redo A; |
redo A; |
| 1370 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1371 |
!!!parse-error (type => 'no DOCTYPE name'); |
!!!parse-error (type => 'no DOCTYPE name'); |
| 1372 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1373 |
## reconsume |
## reconsume |
| 1374 |
|
|
| 1375 |
!!!emit ({type => DOCTYPE_TOKEN}); # incorrect |
!!!emit ({type => DOCTYPE_TOKEN}); # incorrect |
| 1381 |
name => chr ($self->{next_input_character}), |
name => chr ($self->{next_input_character}), |
| 1382 |
correct => 1}; |
correct => 1}; |
| 1383 |
## ISSUE: "Set the token's name name to the" in the spec |
## ISSUE: "Set the token's name name to the" in the spec |
| 1384 |
$self->{state} = 'DOCTYPE name'; |
$self->{state} = DOCTYPE_NAME_STATE; |
| 1385 |
!!!next-input-character; |
!!!next-input-character; |
| 1386 |
redo A; |
redo A; |
| 1387 |
} |
} |
| 1388 |
} elsif ($self->{state} eq 'DOCTYPE name') { |
} elsif ($self->{state} == DOCTYPE_NAME_STATE) { |
| 1389 |
## ISSUE: Redundant "First," in the spec. |
## ISSUE: Redundant "First," in the spec. |
| 1390 |
if ($self->{next_input_character} == 0x0009 or # HT |
if ($self->{next_input_character} == 0x0009 or # HT |
| 1391 |
$self->{next_input_character} == 0x000A or # LF |
$self->{next_input_character} == 0x000A or # LF |
| 1392 |
$self->{next_input_character} == 0x000B or # VT |
$self->{next_input_character} == 0x000B or # VT |
| 1393 |
$self->{next_input_character} == 0x000C or # FF |
$self->{next_input_character} == 0x000C or # FF |
| 1394 |
$self->{next_input_character} == 0x0020) { # SP |
$self->{next_input_character} == 0x0020) { # SP |
| 1395 |
$self->{state} = 'after DOCTYPE name'; |
$self->{state} = AFTER_DOCTYPE_NAME_STATE; |
| 1396 |
!!!next-input-character; |
!!!next-input-character; |
| 1397 |
redo A; |
redo A; |
| 1398 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 1399 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1400 |
!!!next-input-character; |
!!!next-input-character; |
| 1401 |
|
|
| 1402 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 1404 |
redo A; |
redo A; |
| 1405 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1406 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
| 1407 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1408 |
## reconsume |
## reconsume |
| 1409 |
|
|
| 1410 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1418 |
!!!next-input-character; |
!!!next-input-character; |
| 1419 |
redo A; |
redo A; |
| 1420 |
} |
} |
| 1421 |
} elsif ($self->{state} eq 'after DOCTYPE name') { |
} elsif ($self->{state} == AFTER_DOCTYPE_NAME_STATE) { |
| 1422 |
if ($self->{next_input_character} == 0x0009 or # HT |
if ($self->{next_input_character} == 0x0009 or # HT |
| 1423 |
$self->{next_input_character} == 0x000A or # LF |
$self->{next_input_character} == 0x000A or # LF |
| 1424 |
$self->{next_input_character} == 0x000B or # VT |
$self->{next_input_character} == 0x000B or # VT |
| 1428 |
!!!next-input-character; |
!!!next-input-character; |
| 1429 |
redo A; |
redo A; |
| 1430 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 1431 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1432 |
!!!next-input-character; |
!!!next-input-character; |
| 1433 |
|
|
| 1434 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 1436 |
redo A; |
redo A; |
| 1437 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1438 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
| 1439 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1440 |
## reconsume |
## reconsume |
| 1441 |
|
|
| 1442 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1460 |
!!!next-input-character; |
!!!next-input-character; |
| 1461 |
if ($self->{next_input_character} == 0x0043 or # C |
if ($self->{next_input_character} == 0x0043 or # C |
| 1462 |
$self->{next_input_character} == 0x0063) { # c |
$self->{next_input_character} == 0x0063) { # c |
| 1463 |
$self->{state} = 'before DOCTYPE public identifier'; |
$self->{state} = BEFORE_DOCTYPE_PUBLIC_IDENTIFIER_STATE; |
| 1464 |
!!!next-input-character; |
!!!next-input-character; |
| 1465 |
redo A; |
redo A; |
| 1466 |
} |
} |
| 1487 |
!!!next-input-character; |
!!!next-input-character; |
| 1488 |
if ($self->{next_input_character} == 0x004D or # M |
if ($self->{next_input_character} == 0x004D or # M |
| 1489 |
$self->{next_input_character} == 0x006D) { # m |
$self->{next_input_character} == 0x006D) { # m |
| 1490 |
$self->{state} = 'before DOCTYPE system identifier'; |
$self->{state} = BEFORE_DOCTYPE_SYSTEM_IDENTIFIER_STATE; |
| 1491 |
!!!next-input-character; |
!!!next-input-character; |
| 1492 |
redo A; |
redo A; |
| 1493 |
} |
} |
| 1503 |
} |
} |
| 1504 |
|
|
| 1505 |
!!!parse-error (type => 'string after DOCTYPE name'); |
!!!parse-error (type => 'string after DOCTYPE name'); |
| 1506 |
$self->{state} = 'bogus DOCTYPE'; |
$self->{state} = BOGUS_DOCTYPE_STATE; |
| 1507 |
# next-input-character is already done |
# next-input-character is already done |
| 1508 |
redo A; |
redo A; |
| 1509 |
} elsif ($self->{state} eq 'before DOCTYPE public identifier') { |
} elsif ($self->{state} == BEFORE_DOCTYPE_PUBLIC_IDENTIFIER_STATE) { |
| 1510 |
if ({ |
if ({ |
| 1511 |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
| 1512 |
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
| 1516 |
redo A; |
redo A; |
| 1517 |
} elsif ($self->{next_input_character} eq 0x0022) { # " |
} elsif ($self->{next_input_character} eq 0x0022) { # " |
| 1518 |
$self->{current_token}->{public_identifier} = ''; # DOCTYPE |
$self->{current_token}->{public_identifier} = ''; # DOCTYPE |
| 1519 |
$self->{state} = 'DOCTYPE public identifier (double-quoted)'; |
$self->{state} = DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED_STATE; |
| 1520 |
!!!next-input-character; |
!!!next-input-character; |
| 1521 |
redo A; |
redo A; |
| 1522 |
} elsif ($self->{next_input_character} eq 0x0027) { # ' |
} elsif ($self->{next_input_character} eq 0x0027) { # ' |
| 1523 |
$self->{current_token}->{public_identifier} = ''; # DOCTYPE |
$self->{current_token}->{public_identifier} = ''; # DOCTYPE |
| 1524 |
$self->{state} = 'DOCTYPE public identifier (single-quoted)'; |
$self->{state} = DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED_STATE; |
| 1525 |
!!!next-input-character; |
!!!next-input-character; |
| 1526 |
redo A; |
redo A; |
| 1527 |
} elsif ($self->{next_input_character} eq 0x003E) { # > |
} elsif ($self->{next_input_character} eq 0x003E) { # > |
| 1528 |
!!!parse-error (type => 'no PUBLIC literal'); |
!!!parse-error (type => 'no PUBLIC literal'); |
| 1529 |
|
|
| 1530 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1531 |
!!!next-input-character; |
!!!next-input-character; |
| 1532 |
|
|
| 1533 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1537 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1538 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
| 1539 |
|
|
| 1540 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1541 |
## reconsume |
## reconsume |
| 1542 |
|
|
| 1543 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1546 |
redo A; |
redo A; |
| 1547 |
} else { |
} else { |
| 1548 |
!!!parse-error (type => 'string after PUBLIC'); |
!!!parse-error (type => 'string after PUBLIC'); |
| 1549 |
$self->{state} = 'bogus DOCTYPE'; |
$self->{state} = BOGUS_DOCTYPE_STATE; |
| 1550 |
!!!next-input-character; |
!!!next-input-character; |
| 1551 |
redo A; |
redo A; |
| 1552 |
} |
} |
| 1553 |
} elsif ($self->{state} eq 'DOCTYPE public identifier (double-quoted)') { |
} elsif ($self->{state} == DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED_STATE) { |
| 1554 |
if ($self->{next_input_character} == 0x0022) { # " |
if ($self->{next_input_character} == 0x0022) { # " |
| 1555 |
$self->{state} = 'after DOCTYPE public identifier'; |
$self->{state} = AFTER_DOCTYPE_PUBLIC_IDENTIFIER_STATE; |
| 1556 |
|
!!!next-input-character; |
| 1557 |
|
redo A; |
| 1558 |
|
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 1559 |
|
!!!parse-error (type => 'unclosed PUBLIC literal'); |
| 1560 |
|
|
| 1561 |
|
$self->{state} = DATA_STATE; |
| 1562 |
!!!next-input-character; |
!!!next-input-character; |
| 1563 |
|
|
| 1564 |
|
delete $self->{current_token}->{correct}; |
| 1565 |
|
!!!emit ($self->{current_token}); # DOCTYPE |
| 1566 |
|
|
| 1567 |
redo A; |
redo A; |
| 1568 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1569 |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
| 1570 |
|
|
| 1571 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1572 |
## reconsume |
## reconsume |
| 1573 |
|
|
| 1574 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1582 |
!!!next-input-character; |
!!!next-input-character; |
| 1583 |
redo A; |
redo A; |
| 1584 |
} |
} |
| 1585 |
} elsif ($self->{state} eq 'DOCTYPE public identifier (single-quoted)') { |
} elsif ($self->{state} == DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED_STATE) { |
| 1586 |
if ($self->{next_input_character} == 0x0027) { # ' |
if ($self->{next_input_character} == 0x0027) { # ' |
| 1587 |
$self->{state} = 'after DOCTYPE public identifier'; |
$self->{state} = AFTER_DOCTYPE_PUBLIC_IDENTIFIER_STATE; |
| 1588 |
!!!next-input-character; |
!!!next-input-character; |
| 1589 |
redo A; |
redo A; |
| 1590 |
|
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 1591 |
|
!!!parse-error (type => 'unclosed PUBLIC literal'); |
| 1592 |
|
|
| 1593 |
|
$self->{state} = DATA_STATE; |
| 1594 |
|
!!!next-input-character; |
| 1595 |
|
|
| 1596 |
|
delete $self->{current_token}->{correct}; |
| 1597 |
|
!!!emit ($self->{current_token}); # DOCTYPE |
| 1598 |
|
|
| 1599 |
|
redo A; |
| 1600 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1601 |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
!!!parse-error (type => 'unclosed PUBLIC literal'); |
| 1602 |
|
|
| 1603 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1604 |
## reconsume |
## reconsume |
| 1605 |
|
|
| 1606 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1614 |
!!!next-input-character; |
!!!next-input-character; |
| 1615 |
redo A; |
redo A; |
| 1616 |
} |
} |
| 1617 |
} elsif ($self->{state} eq 'after DOCTYPE public identifier') { |
} elsif ($self->{state} == AFTER_DOCTYPE_PUBLIC_IDENTIFIER_STATE) { |
| 1618 |
if ({ |
if ({ |
| 1619 |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
| 1620 |
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
| 1624 |
redo A; |
redo A; |
| 1625 |
} elsif ($self->{next_input_character} == 0x0022) { # " |
} elsif ($self->{next_input_character} == 0x0022) { # " |
| 1626 |
$self->{current_token}->{system_identifier} = ''; # DOCTYPE |
$self->{current_token}->{system_identifier} = ''; # DOCTYPE |
| 1627 |
$self->{state} = 'DOCTYPE system identifier (double-quoted)'; |
$self->{state} = DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE; |
| 1628 |
!!!next-input-character; |
!!!next-input-character; |
| 1629 |
redo A; |
redo A; |
| 1630 |
} elsif ($self->{next_input_character} == 0x0027) { # ' |
} elsif ($self->{next_input_character} == 0x0027) { # ' |
| 1631 |
$self->{current_token}->{system_identifier} = ''; # DOCTYPE |
$self->{current_token}->{system_identifier} = ''; # DOCTYPE |
| 1632 |
$self->{state} = 'DOCTYPE system identifier (single-quoted)'; |
$self->{state} = DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE; |
| 1633 |
!!!next-input-character; |
!!!next-input-character; |
| 1634 |
redo A; |
redo A; |
| 1635 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 1636 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1637 |
!!!next-input-character; |
!!!next-input-character; |
| 1638 |
|
|
| 1639 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 1642 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1643 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
| 1644 |
|
|
| 1645 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1646 |
## reconsume |
## reconsume |
| 1647 |
|
|
| 1648 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1651 |
redo A; |
redo A; |
| 1652 |
} else { |
} else { |
| 1653 |
!!!parse-error (type => 'string after PUBLIC literal'); |
!!!parse-error (type => 'string after PUBLIC literal'); |
| 1654 |
$self->{state} = 'bogus DOCTYPE'; |
$self->{state} = BOGUS_DOCTYPE_STATE; |
| 1655 |
!!!next-input-character; |
!!!next-input-character; |
| 1656 |
redo A; |
redo A; |
| 1657 |
} |
} |
| 1658 |
} elsif ($self->{state} eq 'before DOCTYPE system identifier') { |
} elsif ($self->{state} == BEFORE_DOCTYPE_SYSTEM_IDENTIFIER_STATE) { |
| 1659 |
if ({ |
if ({ |
| 1660 |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
| 1661 |
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
| 1665 |
redo A; |
redo A; |
| 1666 |
} elsif ($self->{next_input_character} == 0x0022) { # " |
} elsif ($self->{next_input_character} == 0x0022) { # " |
| 1667 |
$self->{current_token}->{system_identifier} = ''; # DOCTYPE |
$self->{current_token}->{system_identifier} = ''; # DOCTYPE |
| 1668 |
$self->{state} = 'DOCTYPE system identifier (double-quoted)'; |
$self->{state} = DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE; |
| 1669 |
!!!next-input-character; |
!!!next-input-character; |
| 1670 |
redo A; |
redo A; |
| 1671 |
} elsif ($self->{next_input_character} == 0x0027) { # ' |
} elsif ($self->{next_input_character} == 0x0027) { # ' |
| 1672 |
$self->{current_token}->{system_identifier} = ''; # DOCTYPE |
$self->{current_token}->{system_identifier} = ''; # DOCTYPE |
| 1673 |
$self->{state} = 'DOCTYPE system identifier (single-quoted)'; |
$self->{state} = DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE; |
| 1674 |
!!!next-input-character; |
!!!next-input-character; |
| 1675 |
redo A; |
redo A; |
| 1676 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 1677 |
!!!parse-error (type => 'no SYSTEM literal'); |
!!!parse-error (type => 'no SYSTEM literal'); |
| 1678 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1679 |
!!!next-input-character; |
!!!next-input-character; |
| 1680 |
|
|
| 1681 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1685 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1686 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
| 1687 |
|
|
| 1688 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1689 |
## reconsume |
## reconsume |
| 1690 |
|
|
| 1691 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1694 |
redo A; |
redo A; |
| 1695 |
} else { |
} else { |
| 1696 |
!!!parse-error (type => 'string after SYSTEM'); |
!!!parse-error (type => 'string after SYSTEM'); |
| 1697 |
$self->{state} = 'bogus DOCTYPE'; |
$self->{state} = BOGUS_DOCTYPE_STATE; |
| 1698 |
!!!next-input-character; |
!!!next-input-character; |
| 1699 |
redo A; |
redo A; |
| 1700 |
} |
} |
| 1701 |
} elsif ($self->{state} eq 'DOCTYPE system identifier (double-quoted)') { |
} elsif ($self->{state} == DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE) { |
| 1702 |
if ($self->{next_input_character} == 0x0022) { # " |
if ($self->{next_input_character} == 0x0022) { # " |
| 1703 |
$self->{state} = 'after DOCTYPE system identifier'; |
$self->{state} = AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE; |
| 1704 |
|
!!!next-input-character; |
| 1705 |
|
redo A; |
| 1706 |
|
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 1707 |
|
!!!parse-error (type => 'unclosed PUBLIC literal'); |
| 1708 |
|
|
| 1709 |
|
$self->{state} = DATA_STATE; |
| 1710 |
!!!next-input-character; |
!!!next-input-character; |
| 1711 |
|
|
| 1712 |
|
delete $self->{current_token}->{correct}; |
| 1713 |
|
!!!emit ($self->{current_token}); # DOCTYPE |
| 1714 |
|
|
| 1715 |
redo A; |
redo A; |
| 1716 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1717 |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
| 1718 |
|
|
| 1719 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1720 |
## reconsume |
## reconsume |
| 1721 |
|
|
| 1722 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1730 |
!!!next-input-character; |
!!!next-input-character; |
| 1731 |
redo A; |
redo A; |
| 1732 |
} |
} |
| 1733 |
} elsif ($self->{state} eq 'DOCTYPE system identifier (single-quoted)') { |
} elsif ($self->{state} == DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE) { |
| 1734 |
if ($self->{next_input_character} == 0x0027) { # ' |
if ($self->{next_input_character} == 0x0027) { # ' |
| 1735 |
$self->{state} = 'after DOCTYPE system identifier'; |
$self->{state} = AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE; |
| 1736 |
|
!!!next-input-character; |
| 1737 |
|
redo A; |
| 1738 |
|
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 1739 |
|
!!!parse-error (type => 'unclosed PUBLIC literal'); |
| 1740 |
|
|
| 1741 |
|
$self->{state} = DATA_STATE; |
| 1742 |
!!!next-input-character; |
!!!next-input-character; |
| 1743 |
|
|
| 1744 |
|
delete $self->{current_token}->{correct}; |
| 1745 |
|
!!!emit ($self->{current_token}); # DOCTYPE |
| 1746 |
|
|
| 1747 |
redo A; |
redo A; |
| 1748 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1749 |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
!!!parse-error (type => 'unclosed SYSTEM literal'); |
| 1750 |
|
|
| 1751 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1752 |
## reconsume |
## reconsume |
| 1753 |
|
|
| 1754 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1762 |
!!!next-input-character; |
!!!next-input-character; |
| 1763 |
redo A; |
redo A; |
| 1764 |
} |
} |
| 1765 |
} elsif ($self->{state} eq 'after DOCTYPE system identifier') { |
} elsif ($self->{state} == AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE) { |
| 1766 |
if ({ |
if ({ |
| 1767 |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
| 1768 |
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
| 1771 |
!!!next-input-character; |
!!!next-input-character; |
| 1772 |
redo A; |
redo A; |
| 1773 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 1774 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1775 |
!!!next-input-character; |
!!!next-input-character; |
| 1776 |
|
|
| 1777 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 1780 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1781 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
| 1782 |
|
|
| 1783 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1784 |
## reconsume |
## reconsume |
| 1785 |
|
|
| 1786 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1789 |
redo A; |
redo A; |
| 1790 |
} else { |
} else { |
| 1791 |
!!!parse-error (type => 'string after SYSTEM literal'); |
!!!parse-error (type => 'string after SYSTEM literal'); |
| 1792 |
$self->{state} = 'bogus DOCTYPE'; |
$self->{state} = BOGUS_DOCTYPE_STATE; |
| 1793 |
!!!next-input-character; |
!!!next-input-character; |
| 1794 |
redo A; |
redo A; |
| 1795 |
} |
} |
| 1796 |
} elsif ($self->{state} eq 'bogus DOCTYPE') { |
} elsif ($self->{state} == BOGUS_DOCTYPE_STATE) { |
| 1797 |
if ($self->{next_input_character} == 0x003E) { # > |
if ($self->{next_input_character} == 0x003E) { # > |
| 1798 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1799 |
!!!next-input-character; |
!!!next-input-character; |
| 1800 |
|
|
| 1801 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1804 |
redo A; |
redo A; |
| 1805 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1806 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
| 1807 |
$self->{state} = 'data'; |
$self->{state} = DATA_STATE; |
| 1808 |
## reconsume |
## reconsume |
| 1809 |
|
|
| 1810 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1885 |
$code = $c1_entity_char->{$code}; |
$code = $c1_entity_char->{$code}; |
| 1886 |
} |
} |
| 1887 |
|
|
| 1888 |
return {type => CHARACTER_TOKEN, data => chr $code}; |
return {type => CHARACTER_TOKEN, data => chr $code, |
| 1889 |
|
has_reference => 1}; |
| 1890 |
} # X |
} # X |
| 1891 |
} elsif (0x0030 <= $self->{next_input_character} and |
} elsif (0x0030 <= $self->{next_input_character} and |
| 1892 |
$self->{next_input_character} <= 0x0039) { # 0..9 |
$self->{next_input_character} <= 0x0039) { # 0..9 |
| 1921 |
$code = $c1_entity_char->{$code}; |
$code = $c1_entity_char->{$code}; |
| 1922 |
} |
} |
| 1923 |
|
|
| 1924 |
return {type => CHARACTER_TOKEN, data => chr $code}; |
return {type => CHARACTER_TOKEN, data => chr $code, has_reference => 1}; |
| 1925 |
} else { |
} else { |
| 1926 |
!!!parse-error (type => 'bare nero'); |
!!!parse-error (type => 'bare nero'); |
| 1927 |
!!!back-next-input-character ($self->{next_input_character}); |
!!!back-next-input-character ($self->{next_input_character}); |
| 1969 |
} |
} |
| 1970 |
|
|
| 1971 |
if ($match > 0) { |
if ($match > 0) { |
| 1972 |
return {type => CHARACTER_TOKEN, data => $value}; |
return {type => CHARACTER_TOKEN, data => $value, has_reference => 1}; |
| 1973 |
} elsif ($match < 0) { |
} elsif ($match < 0) { |
| 1974 |
!!!parse-error (type => 'no refc'); |
!!!parse-error (type => 'no refc'); |
| 1975 |
if ($in_attr and $match < -1) { |
if ($in_attr and $match < -1) { |
| 1976 |
return {type => CHARACTER_TOKEN, data => '&'.$entity_name}; |
return {type => CHARACTER_TOKEN, data => '&'.$entity_name}; |
| 1977 |
} else { |
} else { |
| 1978 |
return {type => CHARACTER_TOKEN, data => $value}; |
return {type => CHARACTER_TOKEN, data => $value, has_reference => 1}; |
| 1979 |
} |
} |
| 1980 |
} else { |
} else { |
| 1981 |
!!!parse-error (type => 'bare ero'); |
!!!parse-error (type => 'bare ero'); |
| 1982 |
## NOTE: No characters are consumed in the spec. |
## NOTE: "No characters are consumed" in the spec. |
| 1983 |
return {type => CHARACTER_TOKEN, data => '&'.$value}; |
return {type => CHARACTER_TOKEN, data => '&'.$value}; |
| 1984 |
} |
} |
| 1985 |
} else { |
} else { |
| 2227 |
redo B; |
redo B; |
| 2228 |
} |
} |
| 2229 |
} |
} |
| 2230 |
|
|
| 2231 |
|
$self->{application_cache_selection}->(undef); |
| 2232 |
|
|
| 2233 |
|
# |
| 2234 |
|
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 2235 |
|
if ($token->{tag_name} eq 'html' and |
| 2236 |
|
$token->{attributes}->{manifest}) { |
| 2237 |
|
$self->{application_cache_selection} |
| 2238 |
|
->($token->{attributes}->{manifest}->{value}); |
| 2239 |
|
## ISSUE: No relative reference resolution? |
| 2240 |
|
} else { |
| 2241 |
|
$self->{application_cache_selection}->(undef); |
| 2242 |
|
} |
| 2243 |
|
|
| 2244 |
|
## ISSUE: There is an issue in the spec |
| 2245 |
# |
# |
| 2246 |
} elsif ({ |
} elsif ({ |
|
START_TAG_TOKEN, 1, |
|
| 2247 |
END_TAG_TOKEN, 1, |
END_TAG_TOKEN, 1, |
| 2248 |
END_OF_FILE_TOKEN, 1, |
END_OF_FILE_TOKEN, 1, |
| 2249 |
}->{$token->{type}}) { |
}->{$token->{type}}) { |
| 2250 |
|
$self->{application_cache_selection}->(undef); |
| 2251 |
|
|
| 2252 |
## ISSUE: There is an issue in the spec |
## ISSUE: There is an issue in the spec |
| 2253 |
# |
# |
| 2254 |
} else { |
} else { |
| 2255 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 2256 |
} |
} |
| 2257 |
|
|
| 2258 |
my $root_element; !!!create-element ($root_element, 'html'); |
my $root_element; !!!create-element ($root_element, 'html'); |
| 2259 |
$self->{document}->append_child ($root_element); |
$self->{document}->append_child ($root_element); |
| 2260 |
push @{$self->{open_elements}}, [$root_element, 'html']; |
push @{$self->{open_elements}}, [$root_element, 'html']; |
| 2737 |
!!!next-token; |
!!!next-token; |
| 2738 |
redo B; |
redo B; |
| 2739 |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 2740 |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM or |
if ($self->{insertion_mode} & AFTER_HTML_IMS) { |
|
$self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
|
| 2741 |
# |
# |
| 2742 |
} else { |
} else { |
| 2743 |
## Generate implied end tags |
## Generate implied end tags |
| 2793 |
redo B; |
redo B; |
| 2794 |
} elsif ($token->{type} == COMMENT_TOKEN) { |
} elsif ($token->{type} == COMMENT_TOKEN) { |
| 2795 |
my $comment = $self->{document}->create_comment ($token->{data}); |
my $comment = $self->{document}->create_comment ($token->{data}); |
| 2796 |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM or |
if ($self->{insertion_mode} & AFTER_HTML_IMS) { |
|
$self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
|
| 2797 |
$self->{document}->append_child ($comment); |
$self->{document}->append_child ($comment); |
| 2798 |
} elsif ($self->{insertion_mode} == AFTER_BODY_IM) { |
} elsif ($self->{insertion_mode} == AFTER_BODY_IM) { |
| 2799 |
$self->{open_elements}->[0]->[0]->append_child ($comment); |
$self->{open_elements}->[0]->[0]->append_child ($comment); |
| 2802 |
} |
} |
| 2803 |
!!!next-token; |
!!!next-token; |
| 2804 |
redo B; |
redo B; |
| 2805 |
} elsif ($self->{insertion_mode} == IN_HEAD_IM or |
} elsif ($self->{insertion_mode} & HEAD_IMS) { |
|
$self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM or |
|
|
$self->{insertion_mode} == AFTER_HEAD_IM or |
|
|
$self->{insertion_mode} == BEFORE_HEAD_IM) { |
|
| 2806 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 2807 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 2808 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
| 2911 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 2912 |
} |
} |
| 2913 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 2914 |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
my $meta_el = pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
| 2915 |
|
|
| 2916 |
unless ($self->{confident}) { |
unless ($self->{confident}) { |
|
my $charset; |
|
| 2917 |
if ($token->{attributes}->{charset}) { ## TODO: And if supported |
if ($token->{attributes}->{charset}) { ## TODO: And if supported |
| 2918 |
$charset = $token->{attributes}->{charset}->{value}; |
$self->{change_encoding} |
| 2919 |
} |
->($self, $token->{attributes}->{charset}->{value}); |
| 2920 |
if ($token->{attributes}->{'http-equiv'}) { |
|
| 2921 |
|
$meta_el->[0]->get_attribute_node_ns (undef, 'charset') |
| 2922 |
|
->set_user_data (manakai_has_reference => |
| 2923 |
|
$token->{attributes}->{charset} |
| 2924 |
|
->{has_reference}); |
| 2925 |
|
} elsif ($token->{attributes}->{content}) { |
| 2926 |
## ISSUE: Algorithm name in the spec was incorrect so that not linked to the definition. |
## ISSUE: Algorithm name in the spec was incorrect so that not linked to the definition. |
| 2927 |
if ($token->{attributes}->{'http-equiv'}->{value} |
if ($token->{attributes}->{content}->{value} |
| 2928 |
=~ /\A[^;]*;[\x09-\x0D\x20]*charset[\x09-\x0D\x20]*= |
=~ /\A[^;]*;[\x09-\x0D\x20]*charset[\x09-\x0D\x20]*= |
| 2929 |
[\x09-\x0D\x20]*(?>"([^"]*)"|'([^']*)'| |
[\x09-\x0D\x20]*(?>"([^"]*)"|'([^']*)'| |
| 2930 |
([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) { |
([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) { |
| 2931 |
$charset = defined $1 ? $1 : defined $2 ? $2 : $3; |
$self->{change_encoding} |
| 2932 |
} ## TODO: And if supported |
->($self, defined $1 ? $1 : defined $2 ? $2 : $3); |
| 2933 |
|
$meta_el->[0]->get_attribute_node_ns (undef, 'content') |
| 2934 |
|
->set_user_data (manakai_has_reference => |
| 2935 |
|
$token->{attributes}->{content} |
| 2936 |
|
->{has_reference}); |
| 2937 |
|
} |
| 2938 |
|
} |
| 2939 |
|
} else { |
| 2940 |
|
if ($token->{attributes}->{charset}) { |
| 2941 |
|
$meta_el->[0]->get_attribute_node_ns (undef, 'charset') |
| 2942 |
|
->set_user_data (manakai_has_reference => |
| 2943 |
|
$token->{attributes}->{charset} |
| 2944 |
|
->{has_reference}); |
| 2945 |
|
} |
| 2946 |
|
if ($token->{attributes}->{content}) { |
| 2947 |
|
$meta_el->[0]->get_attribute_node_ns (undef, 'content') |
| 2948 |
|
->set_user_data (manakai_has_reference => |
| 2949 |
|
$token->{attributes}->{content} |
| 2950 |
|
->{has_reference}); |
| 2951 |
} |
} |
|
## TODO: Change the encoding |
|
| 2952 |
} |
} |
| 2953 |
|
|
|
## TODO: Extracting |charset| from |meta|. |
|
| 2954 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} |
| 2955 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 2956 |
!!!next-token; |
!!!next-token; |
| 3199 |
} |
} |
| 3200 |
|
|
| 3201 |
## ISSUE: An issue in the spec. |
## ISSUE: An issue in the spec. |
| 3202 |
} elsif ($self->{insertion_mode} == IN_BODY_IM or |
} elsif ($self->{insertion_mode} & BODY_IMS) { |
|
$self->{insertion_mode} == IN_CELL_IM or |
|
|
$self->{insertion_mode} == IN_CAPTION_IM) { |
|
| 3203 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 3204 |
## NOTE: There is a code clone of "character in body". |
## NOTE: There is a code clone of "character in body". |
| 3205 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 3493 |
} elsif ({ |
} elsif ({ |
| 3494 |
body => 1, col => 1, colgroup => 1, html => 1, |
body => 1, col => 1, colgroup => 1, html => 1, |
| 3495 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 3496 |
if ($self->{insertion_mode} == IN_CELL_IM or |
if ($self->{insertion_mode} & BODY_TABLE_IMS) { |
|
$self->{insertion_mode} == IN_CAPTION_IM) { |
|
| 3497 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3498 |
## Ignore the token |
## Ignore the token |
| 3499 |
!!!next-token; |
!!!next-token; |
| 3519 |
|
|
| 3520 |
$insert = $insert_to_current; |
$insert = $insert_to_current; |
| 3521 |
# |
# |
| 3522 |
} elsif ($self->{insertion_mode} == IN_ROW_IM or |
} elsif ($self->{insertion_mode} & TABLE_IMS) { |
| 3523 |
$self->{insertion_mode} == IN_TABLE_BODY_IM or |
if ($token->{type} == CHARACTER_TOKEN) { |
|
$self->{insertion_mode} == IN_TABLE_IM) { |
|
|
if ($token->{type} == CHARACTER_TOKEN) { |
|
|
## NOTE: There are "character in table" code clones. |
|
| 3524 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 3525 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
| 3526 |
|
|
| 3577 |
|
|
| 3578 |
!!!next-token; |
!!!next-token; |
| 3579 |
redo B; |
redo B; |
| 3580 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 3581 |
if ({ |
if ({ |
| 3582 |
tr => ($self->{insertion_mode} != IN_ROW_IM), |
tr => ($self->{insertion_mode} != IN_ROW_IM), |
| 3583 |
th => 1, td => 1, |
th => 1, td => 1, |
| 3763 |
die "$0: in table: <>: $token->{tag_name}"; |
die "$0: in table: <>: $token->{tag_name}"; |
| 3764 |
} |
} |
| 3765 |
} elsif ($token->{tag_name} eq 'table') { |
} elsif ($token->{tag_name} eq 'table') { |
|
## NOTE: There are code clones for this "table in table" |
|
| 3766 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 3767 |
|
|
| 3768 |
## As if </table> |
## As if </table> |
| 3810 |
|
|
| 3811 |
## reprocess |
## reprocess |
| 3812 |
redo B; |
redo B; |
| 3813 |
} else { |
} else { |
| 3814 |
# |
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
| 3815 |
} |
|
| 3816 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
$insert = $insert_to_foster; |
| 3817 |
|
# |
| 3818 |
|
} |
| 3819 |
|
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 3820 |
if ($token->{tag_name} eq 'tr' and |
if ($token->{tag_name} eq 'tr' and |
| 3821 |
$self->{insertion_mode} == IN_ROW_IM) { |
$self->{insertion_mode} == IN_ROW_IM) { |
| 3822 |
## have an element in table scope |
## have an element in table scope |
| 3975 |
} elsif ({ |
} elsif ({ |
| 3976 |
tbody => 1, tfoot => 1, thead => 1, |
tbody => 1, tfoot => 1, thead => 1, |
| 3977 |
}->{$token->{tag_name}} and |
}->{$token->{tag_name}} and |
| 3978 |
($self->{insertion_mode} == IN_ROW_IM or |
$self->{insertion_mode} & ROW_IMS) { |
|
$self->{insertion_mode} == IN_TABLE_BODY_IM)) { |
|
| 3979 |
if ($self->{insertion_mode} == IN_ROW_IM) { |
if ($self->{insertion_mode} == IN_ROW_IM) { |
| 3980 |
## have an element in table scope |
## have an element in table scope |
| 3981 |
my $i; |
my $i; |
| 4073 |
## Ignore the token |
## Ignore the token |
| 4074 |
!!!next-token; |
!!!next-token; |
| 4075 |
redo B; |
redo B; |
| 4076 |
} else { |
} else { |
| 4077 |
# |
!!!parse-error (type => 'in table:/'.$token->{tag_name}); |
|
} |
|
|
} else { |
|
|
die "$0: $token->{type}: Unknown token type"; |
|
|
} |
|
|
|
|
|
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
|
| 4078 |
|
|
| 4079 |
$insert = $insert_to_foster; |
$insert = $insert_to_foster; |
| 4080 |
# |
# |
| 4081 |
|
} |
| 4082 |
|
} else { |
| 4083 |
|
die "$0: $token->{type}: Unknown token type"; |
| 4084 |
|
} |
| 4085 |
} elsif ($self->{insertion_mode} == IN_COLUMN_GROUP_IM) { |
} elsif ($self->{insertion_mode} == IN_COLUMN_GROUP_IM) { |
| 4086 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 4087 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 4140 |
redo B; |
redo B; |
| 4141 |
} |
} |
| 4142 |
} elsif ($self->{insertion_mode} == IN_SELECT_IM) { |
} elsif ($self->{insertion_mode} == IN_SELECT_IM) { |
| 4143 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 4144 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
| 4145 |
!!!next-token; |
!!!next-token; |
| 4146 |
redo B; |
redo B; |
| 4147 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 4148 |
if ($token->{tag_name} eq 'option') { |
if ($token->{tag_name} eq 'option') { |
| 4149 |
if ($self->{open_elements}->[-1]->[1] eq 'option') { |
if ($self->{open_elements}->[-1]->[1] eq 'option') { |
| 4150 |
## As if </option> |
## As if </option> |
| 4197 |
|
|
| 4198 |
!!!next-token; |
!!!next-token; |
| 4199 |
redo B; |
redo B; |
| 4200 |
} else { |
} else { |
| 4201 |
# |
!!!parse-error (type => 'in select:'.$token->{tag_name}); |
| 4202 |
} |
## Ignore the token |
| 4203 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
!!!next-token; |
| 4204 |
|
redo B; |
| 4205 |
|
} |
| 4206 |
|
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 4207 |
if ($token->{tag_name} eq 'optgroup') { |
if ($token->{tag_name} eq 'optgroup') { |
| 4208 |
if ($self->{open_elements}->[-1]->[1] eq 'option' and |
if ($self->{open_elements}->[-1]->[1] eq 'option' and |
| 4209 |
$self->{open_elements}->[-2]->[1] eq 'optgroup') { |
$self->{open_elements}->[-2]->[1] eq 'optgroup') { |
| 4305 |
|
|
| 4306 |
## reprocess |
## reprocess |
| 4307 |
redo B; |
redo B; |
| 4308 |
} else { |
} else { |
| 4309 |
# |
!!!parse-error (type => 'in select:/'.$token->{tag_name}); |
|
} |
|
|
} else { |
|
|
# |
|
|
} |
|
|
|
|
|
!!!parse-error (type => 'in select:'.$token->{tag_name}); |
|
| 4310 |
## Ignore the token |
## Ignore the token |
| 4311 |
!!!next-token; |
!!!next-token; |
| 4312 |
redo B; |
redo B; |
| 4313 |
} elsif ($self->{insertion_mode} == AFTER_BODY_IM or |
} |
| 4314 |
$self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
} else { |
| 4315 |
|
die "$0: $token->{type}: Unknown token type"; |
| 4316 |
|
} |
| 4317 |
|
} elsif ($self->{insertion_mode} & BODY_AFTER_IMS) { |
| 4318 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 4319 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 4320 |
my $data = $1; |
my $data = $1; |
| 4384 |
} else { |
} else { |
| 4385 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 4386 |
} |
} |
| 4387 |
} elsif ($self->{insertion_mode} == IN_FRAMESET_IM or |
} elsif ($self->{insertion_mode} & FRAME_IMS) { |
|
$self->{insertion_mode} == AFTER_FRAMESET_IM or |
|
|
$self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
|
| 4388 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 4389 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 4390 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
| 4521 |
} elsif ($token->{tag_name} eq 'meta') { |
} elsif ($token->{tag_name} eq 'meta') { |
| 4522 |
## NOTE: This is an "as if in head" code clone, only "-t" differs |
## NOTE: This is an "as if in head" code clone, only "-t" differs |
| 4523 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
| 4524 |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
my $meta_el = pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
| 4525 |
|
|
| 4526 |
unless ($self->{confident}) { |
unless ($self->{confident}) { |
|
my $charset; |
|
| 4527 |
if ($token->{attributes}->{charset}) { ## TODO: And if supported |
if ($token->{attributes}->{charset}) { ## TODO: And if supported |
| 4528 |
$charset = $token->{attributes}->{charset}->{value}; |
$self->{change_encoding} |
| 4529 |
} |
->($self, $token->{attributes}->{charset}->{value}); |
| 4530 |
if ($token->{attributes}->{'http-equiv'}) { |
|
| 4531 |
|
$meta_el->[0]->get_attribute_node_ns (undef, 'charset') |
| 4532 |
|
->set_user_data (manakai_has_reference => |
| 4533 |
|
$token->{attributes}->{charset} |
| 4534 |
|
->{has_reference}); |
| 4535 |
|
} elsif ($token->{attributes}->{content}) { |
| 4536 |
## ISSUE: Algorithm name in the spec was incorrect so that not linked to the definition. |
## ISSUE: Algorithm name in the spec was incorrect so that not linked to the definition. |
| 4537 |
if ($token->{attributes}->{'http-equiv'}->{value} |
if ($token->{attributes}->{content}->{value} |
| 4538 |
=~ /\A[^;]*;[\x09-\x0D\x20]*charset[\x09-\x0D\x20]*= |
=~ /\A[^;]*;[\x09-\x0D\x20]*charset[\x09-\x0D\x20]*= |
| 4539 |
[\x09-\x0D\x20]*(?>"([^"]*)"|'([^']*)'| |
[\x09-\x0D\x20]*(?>"([^"]*)"|'([^']*)'| |
| 4540 |
([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) { |
([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) { |
| 4541 |
$charset = defined $1 ? $1 : defined $2 ? $2 : $3; |
$self->{change_encoding} |
| 4542 |
} ## TODO: And if supported |
->($self, defined $1 ? $1 : defined $2 ? $2 : $3); |
| 4543 |
|
$meta_el->[0]->get_attribute_node_ns (undef, 'content') |
| 4544 |
|
->set_user_data (manakai_has_reference => |
| 4545 |
|
$token->{attributes}->{content} |
| 4546 |
|
->{has_reference}); |
| 4547 |
|
} |
| 4548 |
|
} |
| 4549 |
|
} else { |
| 4550 |
|
if ($token->{attributes}->{charset}) { |
| 4551 |
|
$meta_el->[0]->get_attribute_node_ns (undef, 'charset') |
| 4552 |
|
->set_user_data (manakai_has_reference => |
| 4553 |
|
$token->{attributes}->{charset} |
| 4554 |
|
->{has_reference}); |
| 4555 |
|
} |
| 4556 |
|
if ($token->{attributes}->{content}) { |
| 4557 |
|
$meta_el->[0]->get_attribute_node_ns (undef, 'content') |
| 4558 |
|
->set_user_data (manakai_has_reference => |
| 4559 |
|
$token->{attributes}->{content} |
| 4560 |
|
->{has_reference}); |
| 4561 |
} |
} |
|
## TODO: Change the encoding |
|
| 4562 |
} |
} |
| 4563 |
|
|
| 4564 |
!!!next-token; |
!!!next-token; |
| 4865 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4866 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 4867 |
if ($node->[1] eq 'nobr') { |
if ($node->[1] eq 'nobr') { |
| 4868 |
!!!parse-error (type => 'not closed:nobr'); |
!!!parse-error (type => 'in nobr:nobr'); |
| 4869 |
!!!back-token; |
!!!back-token; |
| 4870 |
$token = {type => END_TAG_TOKEN, tag_name => 'nobr'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'nobr'}; |
| 4871 |
redo B; |
redo B; |
| 5070 |
noframes => 1, |
noframes => 1, |
| 5071 |
noscript => 0, ## TODO: 1 if scripting is enabled |
noscript => 0, ## TODO: 1 if scripting is enabled |
| 5072 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 5073 |
## NOTE: There are two "as if in body" code clones. |
## NOTE: There is an "as if in body" code clone. |
| 5074 |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert); |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert); |
| 5075 |
redo B; |
redo B; |
| 5076 |
} elsif ($token->{tag_name} eq 'select') { |
} elsif ($token->{tag_name} eq 'select') { |
| 5226 |
if ($self->{open_elements}->[-1]->[1] eq $token->{tag_name}) { |
if ($self->{open_elements}->[-1]->[1] eq $token->{tag_name}) { |
| 5227 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5228 |
} else { |
} else { |
| 5229 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 5230 |
} |
} |
| 5231 |
|
|
| 5232 |
undef $self->{form_element}; |
undef $self->{form_element}; |
| 5264 |
} # INSCOPE |
} # INSCOPE |
| 5265 |
|
|
| 5266 |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 5267 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 5268 |
} |
} |
| 5269 |
|
|
| 5270 |
splice @{$self->{open_elements}}, $i if defined $i; |
splice @{$self->{open_elements}}, $i if defined $i; |
| 5333 |
|
|
| 5334 |
## Step 2 |
## Step 2 |
| 5335 |
if ($token->{tag_name} ne $self->{open_elements}->[-1]->[1]) { |
if ($token->{tag_name} ne $self->{open_elements}->[-1]->[1]) { |
| 5336 |
|
## NOTE: <x><y></x> |
| 5337 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 5338 |
} |
} |
| 5339 |
|
|
| 5384 |
my $s = \$_[0]; |
my $s = \$_[0]; |
| 5385 |
my $onerror = $_[1]; |
my $onerror = $_[1]; |
| 5386 |
|
|
| 5387 |
|
## ISSUE: Should {confident} be true? |
| 5388 |
|
|
| 5389 |
my $nt = $node->node_type; |
my $nt = $node->node_type; |
| 5390 |
if ($nt == 9) { |
if ($nt == 9) { |
| 5391 |
# MUST |
# MUST |
| 5538 |
|
|
| 5539 |
} # tree construction stage |
} # tree construction stage |
| 5540 |
|
|
| 5541 |
sub get_inner_html ($$$) { |
package Whatpm::HTML::RestartParser; |
| 5542 |
my (undef, $node, $on_error) = @_; |
push our @ISA, 'Error'; |
|
|
|
|
## Step 1 |
|
|
my $s = ''; |
|
|
|
|
|
my $in_cdata; |
|
|
my $parent = $node; |
|
|
while (defined $parent) { |
|
|
if ($parent->node_type == 1 and |
|
|
$parent->namespace_uri eq 'http://www.w3.org/1999/xhtml' and |
|
|
{ |
|
|
style => 1, script => 1, xmp => 1, iframe => 1, |
|
|
noembed => 1, noframes => 1, noscript => 1, |
|
|
}->{$parent->local_name}) { ## TODO: case thingy |
|
|
$in_cdata = 1; |
|
|
} |
|
|
$parent = $parent->parent_node; |
|
|
} |
|
|
|
|
|
## Step 2 |
|
|
my @node = @{$node->child_nodes}; |
|
|
C: while (@node) { |
|
|
my $child = shift @node; |
|
|
unless (ref $child) { |
|
|
if ($child eq 'cdata-out') { |
|
|
$in_cdata = 0; |
|
|
} else { |
|
|
$s .= $child; # end tag |
|
|
} |
|
|
next C; |
|
|
} |
|
|
|
|
|
my $nt = $child->node_type; |
|
|
if ($nt == 1) { # Element |
|
|
my $tag_name = $child->tag_name; ## TODO: manakai_tag_name |
|
|
$s .= '<' . $tag_name; |
|
|
## NOTE: Non-HTML case: |
|
|
## <http://permalink.gmane.org/gmane.org.w3c.whatwg.discuss/11191> |
|
|
|
|
|
my @attrs = @{$child->attributes}; # sort order MUST be stable |
|
|
for my $attr (@attrs) { # order is implementation dependent |
|
|
my $attr_name = $attr->name; ## TODO: manakai_name |
|
|
$s .= ' ' . $attr_name . '="'; |
|
|
my $attr_value = $attr->value; |
|
|
## escape |
|
|
$attr_value =~ s/&/&/g; |
|
|
$attr_value =~ s/</</g; |
|
|
$attr_value =~ s/>/>/g; |
|
|
$attr_value =~ s/"/"/g; |
|
|
$s .= $attr_value . '"'; |
|
|
} |
|
|
$s .= '>'; |
|
|
|
|
|
next C if { |
|
|
area => 1, base => 1, basefont => 1, bgsound => 1, |
|
|
br => 1, col => 1, embed => 1, frame => 1, hr => 1, |
|
|
img => 1, input => 1, link => 1, meta => 1, param => 1, |
|
|
spacer => 1, wbr => 1, |
|
|
}->{$tag_name}; |
|
|
|
|
|
$s .= "\x0A" if $tag_name eq 'pre' or $tag_name eq 'textarea'; |
|
|
|
|
|
if (not $in_cdata and { |
|
|
style => 1, script => 1, xmp => 1, iframe => 1, |
|
|
noembed => 1, noframes => 1, noscript => 1, |
|
|
plaintext => 1, |
|
|
}->{$tag_name}) { |
|
|
unshift @node, 'cdata-out'; |
|
|
$in_cdata = 1; |
|
|
} |
|
|
|
|
|
unshift @node, @{$child->child_nodes}, '</' . $tag_name . '>'; |
|
|
} elsif ($nt == 3 or $nt == 4) { |
|
|
if ($in_cdata) { |
|
|
$s .= $child->data; |
|
|
} else { |
|
|
my $value = $child->data; |
|
|
$value =~ s/&/&/g; |
|
|
$value =~ s/</</g; |
|
|
$value =~ s/>/>/g; |
|
|
$value =~ s/"/"/g; |
|
|
$s .= $value; |
|
|
} |
|
|
} elsif ($nt == 8) { |
|
|
$s .= '<!--' . $child->data . '-->'; |
|
|
} elsif ($nt == 10) { |
|
|
$s .= '<!DOCTYPE ' . $child->name . '>'; |
|
|
} elsif ($nt == 5) { # entrefs |
|
|
push @node, @{$child->child_nodes}; |
|
|
} else { |
|
|
$on_error->($child) if defined $on_error; |
|
|
} |
|
|
## ISSUE: This code does not support PIs. |
|
|
} # C |
|
|
|
|
|
## Step 3 |
|
|
return \$s; |
|
|
} # get_inner_html |
|
| 5543 |
|
|
| 5544 |
1; |
1; |
| 5545 |
# $Date$ |
# $Date$ |