]> git.deb.at Git - deb/packages.git/commitdiff
Handle broken Homepage fields more gracefully
authorFrank Lichtenheld <frank@lichtenheld.de>
Sun, 9 Dec 2007 17:18:03 +0000 (18:18 +0100)
committerFrank Lichtenheld <frank@lichtenheld.de>
Sun, 9 Dec 2007 17:18:03 +0000 (18:18 +0100)
They exist, so handle them...

lib/Packages/Template.pm
templates/html/show.tmpl

index 28d8d1ed4c84588b8dd0a2654c10350390c69ade..a3268a35f046d5141003e1d6da5b6fffd7540010 100644 (file)
@@ -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(@_,'<>&"') };
index 275ccc397ea3d1cafc7a029c2652f3376499c21d..d68b02c6adff1669d57efd77d77e164167679ddd 100644 (file)
    IF url %]
 <h3>[% g('External Resources:') %]</h3>
 <ul>
-<li><a href="[% url %]">[% g('Homepage') %]</a> [[% extract_host(url) %]]</li>
+<li><a href="[% url | uri %]">[% g('Homepage') %]</a> [[% extract_host(url) | html %]]</li>
 </ul>
 [% END %]