2743 |
|
|
2744 |
## Step 3 |
## Step 3 |
2745 |
S3: { |
S3: { |
|
## ISSUE: Oops! "If node is the first node in the stack of open |
|
|
## elements, then set last to true. If the context element of the |
|
|
## HTML fragment parsing algorithm is neither a td element nor a |
|
|
## th element, then set node to the context element. (fragment case)": |
|
|
## The second "if" is in the scope of the first "if"!? |
|
2746 |
if ($self->{open_elements}->[0]->[0] eq $node->[0]) { |
if ($self->{open_elements}->[0]->[0] eq $node->[0]) { |
2747 |
$last = 1; |
$last = 1; |
2748 |
if (defined $self->{inner_html_node}) { |
if (defined $self->{inner_html_node}) { |
3208 |
} # FET |
} # FET |
3209 |
}; # $formatting_end_tag |
}; # $formatting_end_tag |
3210 |
|
|
3211 |
|
## NOTE: $open_tables->[-1]->[0] is the "current table". |
3212 |
|
## NOTE: $open_tables->[-1]->[1] is the "tainted" flag. |
3213 |
|
my $open_tables = [[$self->{open_elements}->[0]->[0]]]; |
3214 |
|
|
3215 |
my $insert_to_current = sub { |
my $insert_to_current = sub { |
3216 |
$self->{open_elements}->[-1]->[0]->append_child ($_[0]); |
$self->{open_elements}->[-1]->[0]->append_child ($_[0]); |
3217 |
}; # $insert_to_current |
}; # $insert_to_current |
3218 |
|
|
3219 |
my $insert_to_foster = sub { |
my $insert_to_foster = sub { |
3220 |
my $child = shift; |
my $child = shift; |
3221 |
if ({ |
if ({ |
3222 |
table => 1, tbody => 1, tfoot => 1, |
table => 1, tbody => 1, tfoot => 1, thead => 1, tr => 1, |
3223 |
thead => 1, tr => 1, |
}->{$self->{open_elements}->[-1]->[1]}) { |
3224 |
}->{$self->{open_elements}->[-1]->[1]}) { |
# MUST |
3225 |
# MUST |
my $foster_parent_element; |
3226 |
my $foster_parent_element; |
my $next_sibling; |
|
my $next_sibling; |
|
3227 |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
3228 |
if ($self->{open_elements}->[$_]->[1] eq 'table') { |
if ($self->{open_elements}->[$_]->[1] eq 'table') { |
3229 |
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
3243 |
unless defined $foster_parent_element; |
unless defined $foster_parent_element; |
3244 |
$foster_parent_element->insert_before |
$foster_parent_element->insert_before |
3245 |
($child, $next_sibling); |
($child, $next_sibling); |
3246 |
} else { |
$open_tables->[-1]->[1] = 1; # tainted |
3247 |
!!!cp ('t72'); |
} else { |
3248 |
$self->{open_elements}->[-1]->[0]->append_child ($child); |
!!!cp ('t72'); |
3249 |
} |
$self->{open_elements}->[-1]->[0]->append_child ($child); |
3250 |
|
} |
3251 |
}; # $insert_to_foster |
}; # $insert_to_foster |
3252 |
|
|
3253 |
my $insert; |
my $insert; |
4155 |
# |
# |
4156 |
} elsif ($self->{insertion_mode} & TABLE_IMS) { |
} elsif ($self->{insertion_mode} & TABLE_IMS) { |
4157 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
4158 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if (not $open_tables->[-1]->[1] and # tainted |
4159 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
$token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
4160 |
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
4161 |
|
|
4162 |
unless (length $token->{data}) { |
unless (length $token->{data}) { |
4163 |
!!!cp ('t194'); |
!!!cp ('t194'); |
4164 |
!!!next-token; |
!!!next-token; |
4165 |
redo B; |
redo B; |
4166 |
} else { |
} else { |
4167 |
!!!cp ('t195'); |
!!!cp ('t195'); |
4168 |
} |
} |
4169 |
} |
} |
4170 |
|
|
4171 |
!!!parse-error (type => 'in table:#character'); |
!!!parse-error (type => 'in table:#character'); |
4172 |
|
|
4213 |
($self->{document}->create_text_node ($token->{data}), |
($self->{document}->create_text_node ($token->{data}), |
4214 |
$next_sibling); |
$next_sibling); |
4215 |
} |
} |
4216 |
} else { |
$open_tables->[-1]->[1] = 1; # tainted |
4217 |
!!!cp ('t200'); |
} else { |
4218 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
!!!cp ('t200'); |
4219 |
} |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
4220 |
|
} |
4221 |
|
|
4222 |
!!!next-token; |
!!!next-token; |
4223 |
redo B; |
redo B; |
4224 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
4225 |
if ({ |
if ({ |
4226 |
tr => ($self->{insertion_mode} != IN_ROW_IM), |
tr => ($self->{insertion_mode} != IN_ROW_IM), |
4477 |
} |
} |
4478 |
|
|
4479 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
4480 |
|
pop @{$open_tables}; |
4481 |
|
|
4482 |
$self->_reset_insertion_mode; |
$self->_reset_insertion_mode; |
4483 |
|
|
4647 |
} |
} |
4648 |
|
|
4649 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
4650 |
|
pop @{$open_tables}; |
4651 |
|
|
4652 |
$self->_reset_insertion_mode; |
$self->_reset_insertion_mode; |
4653 |
|
|
5729 |
} # INSCOPE |
} # INSCOPE |
5730 |
|
|
5731 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
5732 |
|
push @{$open_tables}, [$self->{open_elements}->[-1]->[0]]; |
5733 |
|
|
5734 |
$self->{insertion_mode} = IN_TABLE_IM; |
$self->{insertion_mode} = IN_TABLE_IM; |
5735 |
|
|
5736 |
!!!next-token; |
!!!next-token; |