+middleman
[MyWeb.git] / Web.pm
diff --git a/Web.pm b/Web.pm
index ddd1f98..4436247 100644 (file)
--- a/Web.pm
+++ b/Web.pm
@@ -55,6 +55,7 @@ BEGIN
 
 #              print STDERR "Wuse $file\n";
                Wrequire $file;
+               local $Exporter::ExportLevel=$Exporter::ExportLevel+1;
                $file->import(@list);
                1;
        }
@@ -267,6 +268,17 @@ sub footer (;$)
                print "</p>\n";
                }
 
+       for my $package (
+                       $W->{"__PACKAGE__"},
+                       __PACKAGE__,
+                       @{$W->{"packages_used"}{$Apache::Registry::curstash}},
+                       ) {
+               my $cvs_id=(eval('$'.$package."::CVS_ID")
+#                              || $package     # debug
+                               );
+               print '<!-- '.$package.' - $'.$cvs_id.'$ -->'."\n" if $cvs_id;
+               }
+
        if ($W->{"heading"}) {
                do { &{$_}() if $_; } for ($W->{"footing"});
                }
@@ -316,6 +328,8 @@ my($url,$contents,%args)=@_;
 
        do { $$_=1 if !defined $$_; } for (\$args{"size"});
        $contents=CGI::escapeHTML($url) if !defined $contents;
+       $contents=~s#<a\b[^>]*>##gi;
+       $contents=~s#</a>##gi;
 
        my $r='<a href="';
        my $urlent=CGI::escapeHTML($url);
@@ -329,6 +343,8 @@ my($url,$contents,%args)=@_;
                { $r.=$urlent; }
        else    # unknown client, &CGI::escapeHTML should not be needed here
                { $r.=CGI::escapeHTML(top_dir()."/Redirect.pl?location=".uri_escape($url)); }
+       $r.='"';
+       do { $r.=" $_" if $_; } for ($args{"attr"});
        $r.='">'.$contents.'</a>';
        if ($args{"size"} && url_is_local($url) && $url=~/[.](?:gz|Z|rpm|zip|deb|lha)/) {       # Downloadable?
                if (!-r $url)
@@ -420,6 +436,7 @@ my($file_base,$alt,$attrs)=@_;
 
        my $file=img_src $file_base;
        my($width,$height)=Image::Size::imgsize($file);
+       $alt=~s/<[^>]*>//g;
        $alt=CGI::escapeHTML($alt);
        return "<img src=\"$file\" alt=\"$alt\" title=\"$alt\" ".img_size($width,$height)
                        .(!$attrs ? "" : " ".$attrs)." />";
@@ -471,9 +488,10 @@ my($class)=@_;
                }
        print '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'."\n";
        print '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">'."\n";
-       print '<head><title>'.CGI::escapeHTML($W->{"title_prefix"})
-                       .join("",map({ ': '.CGI::escapeHTML($_); } ($W->{"title"} || ())))
-                       .'</title>'."\n";
+       my $title=$W->{"title_prefix"}.join("",map({ ': '.$_; } ($W->{"title"} || ())));
+       $title=~s#<[^>]*>##g;
+       print "<head>";
+       print "<title>$title</title>\n";
 
        if ($W->{"have_css"}) {
                print <<'HERE';