]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/meta.pm
Add missing plugin section, and deal with missing sections with a warning.
[ikiwiki.git] / IkiWiki / Plugin / meta.pm
index 28b1a1ad6e69624791492a8582dce79360acee89..421f1dc86a83d33ac823f9989ad9e42c6dea12c9 100644 (file)
@@ -285,6 +285,13 @@ sub preprocess (@) {
                        join(' ', map { "$_=\"$params{$_}\"" } keys %params).
                        ' />', $page, $destpage);
        }
+       elsif ($key eq 'keywords') {
+               # Make sure the keyword string is safe: only allow alphanumeric
+               # characters, space and comma and strip the rest.
+               $value =~ s/[^[:alnum:], ]+//g;
+               push @{$metaheaders{$page}}, '<meta name="keywords"'.
+                       ' content="'.encode_entities($value).'" />';
+       }
        else {
                push @{$metaheaders{$page}}, scrub('<meta name="'.
                        encode_entities($key).'" content="'.
@@ -311,8 +318,9 @@ sub pagetemplate (@) {
                $template->param(title_overridden => 1);
        }
 
-       foreach my $field (qw{author authorurl}) {
-               $template->param($field => $pagestate{$page}{meta}{$field})
+       foreach my $field (qw{authorurl}) {
+               eval q{use HTML::Entities};
+               $template->param($field => HTML::Entities::encode_entities($pagestate{$page}{meta}{$field}))
                        if exists $pagestate{$page}{meta}{$field} && $template->query(name => $field);
        }
 
@@ -323,7 +331,7 @@ sub pagetemplate (@) {
                }
        }
 
-       foreach my $field (qw{description}) {
+       foreach my $field (qw{description author}) {
                eval q{use HTML::Entities};
                $template->param($field => HTML::Entities::encode_numeric($pagestate{$page}{meta}{$field}))
                        if exists $pagestate{$page}{meta}{$field} && $template->query(name => $field);