Debian lenny version packages
[pkg-perl] / deb-src / libhtml-tree-perl / libhtml-tree-perl-3.23 / t / attributes.t
1 #!/usr/bin/perl
2
3 # HTML::TreeBuilder invokes HTML::Entities::decode on the contents of
4 # HREF attributes.  Some CGI-based sites use lang=en or such for
5 # internationalization.  When this parameter is after an ampersand,
6 # the resulting &lang is decoded, breaking the link.  "sub" is another
7 # popular one.
8
9 # Test provided by Rocco Caputo
10
11 use warnings;
12 use strict;
13
14 use Test::More tests => 1;
15 use HTML::TreeBuilder;
16
17 my $tb = HTML::TreeBuilder->new();
18 $tb->parse(
19         "<a href='http://wherever/moo.cgi?xyz=123&lang=en'>Test</a>"
20 );
21
22 my @links = $tb->look_down( sub { $_[0]->tag eq "a" } );
23 my $href = $links[0]->attr("href");
24
25 ok($href =~ /lang/, "href should contain 'lang' (is: $href)");
26
27 exit;
28