summaryrefslogtreecommitdiff
path: root/t/attr-encoded.t
blob: 4d458eb76c74c744ae33b33a8e6bade814d0746d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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="&amp;&lt;&gt">
EOT

$p->parse($html)->eof;

is($text, 'S[tag arg=&amp;&lt;&gt]');

$text = "";
$p->attr_encoded(0);
$p->parse($html)->eof;

is($text, 'S[tag arg=&<>]');