[Bps-public-commit] r11954 - in HTML-RewriteAttributes: . lib/HTML lib/HTML/RewriteAttributes
sartak at bestpractical.com
sartak at bestpractical.com
Tue Apr 29 16:12:01 EDT 2008
Author: sartak
Date: Tue Apr 29 16:12:00 2008
New Revision: 11954
Added:
HTML-RewriteAttributes/t/010-resolvelink.t
Modified:
HTML-RewriteAttributes/ (props changed)
HTML-RewriteAttributes/lib/HTML/RewriteAttributes.pm
HTML-RewriteAttributes/lib/HTML/RewriteAttributes/Links.pm
Log:
r54645 at onn: sartak | 2008-04-29 16:11:55 -0400
Add Miyagawa's HTML::ResolveLink tests, fix <base> handling
Modified: HTML-RewriteAttributes/lib/HTML/RewriteAttributes.pm
==============================================================================
--- HTML-RewriteAttributes/lib/HTML/RewriteAttributes.pm (original)
+++ HTML-RewriteAttributes/lib/HTML/RewriteAttributes.pm Tue Apr 29 16:12:00 2008
@@ -11,8 +11,8 @@
sub new {
my $class = shift;
return $class->SUPER::new(
- start_h => [ \&_start_tag, "self,tagname,attr,attrseq,text" ],
- default_h => [ \&_default, "self,tagname,attr,text" ],
+ start_h => [ '_start_tag', "self,tagname,attr,attrseq,text" ],
+ default_h => [ '_default', "self,tagname,attr,text" ],
);
}
Modified: HTML-RewriteAttributes/lib/HTML/RewriteAttributes/Links.pm
==============================================================================
--- HTML-RewriteAttributes/lib/HTML/RewriteAttributes/Links.pm (original)
+++ HTML-RewriteAttributes/lib/HTML/RewriteAttributes/Links.pm Tue Apr 29 16:12:00 2008
@@ -41,9 +41,9 @@
# if we see a base tag, steal its href for future link resolution
sub _start_tag {
my $self = shift;
- my ($tagname, $attr, $attrseq, $text) = @_;
+ my ($tag, $attr, $attrseq, $text) = @_;
- if ($tagname eq 'base' && defined $attr->{href}) {
+ if ($tag eq 'base' && defined $attr->{href}) {
$self->{rewrite_link_base} = $attr->{href};
}
Added: HTML-RewriteAttributes/t/010-resolvelink.t
==============================================================================
--- (empty file)
+++ HTML-RewriteAttributes/t/010-resolvelink.t Tue Apr 29 16:12:00 2008
@@ -0,0 +1,49 @@
+# these tests are taken from HTML::ResolveLink, written by miyagawa
+use strict;
+use Test::More tests => 3;
+use HTML::RewriteAttributes::Links;
+
+my $base = "http://www.example.com/base/";
+my $resolver = "HTML::RewriteAttributes::Links";
+
+my $html = $resolver->rewrite(<<'HTML', $base);
+<a href="/foo">foo</a><img src="/bar.gif" alt="foo & bar" /> foobar
+<a href="mailto:foobar at example.com">hey &</a>
+<a href="foo.html" onclick="foobar()">bar</a><br />
+<a href="http://www.example.net/">bar</a>
+<!-- hello -->
+HTML
+
+is $html, <<'HTML';
+<a href="http://www.example.com/foo">foo</a><img src="http://www.example.com/bar.gif" alt="foo & bar" /> foobar
+<a href="mailto:foobar at example.com">hey &</a>
+<a href="http://www.example.com/base/foo.html" onclick="foobar()">bar</a><br />
+<a href="http://www.example.net/">bar</a>
+<!-- hello -->
+HTML
+
+$html = $resolver->rewrite(<<'HTML', $base);
+<base href="http://www.google.com/">
+<a href="baz">foo</a>
+<base href="http://www.example.com/">
+<a href="baz">foo</a>
+HTML
+
+is $html, <<'HTML', '<base>';
+<base href="http://www.google.com/">
+<a href="http://www.google.com/baz">foo</a>
+<base href="http://www.example.com/">
+<a href="http://www.example.com/baz">foo</a>
+HTML
+ ;
+
+$html = $resolver->rewrite(<<'HTML', $base);
+<a href="baz">&</a>
+"foo"
+HTML
+
+is $html, <<'HTML', 'HTML entities';
+<a href="http://www.example.com/base/baz">&</a>
+"foo"
+HTML
+ ;
More information about the Bps-public-commit
mailing list