diff options
Diffstat (limited to 't/attr-encoded.t')
-rw-r--r-- | t/attr-encoded.t | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/t/attr-encoded.t b/t/attr-encoded.t new file mode 100644 index 0000000..4d458eb --- /dev/null +++ b/t/attr-encoded.t @@ -0,0 +1,32 @@ +use strict; +use Test::More tests => 2; + +use HTML::Parser (); +my $p = HTML::Parser->new(); +$p->attr_encoded(1); + +my $text = ""; +$p->handler(start => + sub { + my($tag, $attr) = @_; + $text .= "S[$tag"; + for my $k (sort keys %$attr) { + my $v = $attr->{$k}; + $text .= " $k=$v"; + } + $text .= "]"; + }, "tagname,attr"); + +my $html = <<'EOT'; +<tag arg="&<>"> +EOT + +$p->parse($html)->eof; + +is($text, 'S[tag arg=&<>]'); + +$text = ""; +$p->attr_encoded(0); +$p->parse($html)->eof; + +is($text, 'S[tag arg=&<>]'); |