From: Frank Lichtenheld Date: Sun, 9 Dec 2007 17:18:03 +0000 (+0100) Subject: Handle broken Homepage fields more gracefully X-Git-Url: https://git.deb.at/?p=deb%2Fpackages.git;a=commitdiff_plain;h=3954845023a55026b0e57a131877cfd1b7fdc0b7;ds=sidebyside Handle broken Homepage fields more gracefully They exist, so handle them... --- diff --git a/lib/Packages/Template.pm b/lib/Packages/Template.pm index 28d8d1e..a3268a3 100644 --- a/lib/Packages/Template.pm +++ b/lib/Packages/Template.pm @@ -38,10 +38,14 @@ sub new { if ($vars->{cat}) { $vars->{g} = sub { return Packages::I18N::Locale::g($vars->{cat}, @_) }; } - $vars->{extract_host} = sub { my $uri = URI->new($_[0]); - my $host = $uri->host; - $host .= ':'.$uri->port if $uri->port != $uri->default_port; - return $host; + $vars->{extract_host} = sub { my $uri_str = $_[0]; + my $uri = URI->new($uri_str); + if ($uri->can('host')) { + my $host = $uri->host; + $host .= ':'.$uri->port if $uri->port != $uri->default_port; + return $host; + } + return $uri_str; }; # needed to work around the limitations of the the FILTER syntax $vars->{html_encode} = sub { return HTML::Entities::encode_entities(@_,'<>&"') }; diff --git a/templates/html/show.tmpl b/templates/html/show.tmpl index 275ccc3..d68b02c 100644 --- a/templates/html/show.tmpl +++ b/templates/html/show.tmpl @@ -121,7 +121,7 @@ IF url %]

[% g('External Resources:') %]

[% END %]