]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/meta.pm
the problem is with YAML::Any, hardcoding YAML::XS fixes the issue. delimiters are...
[git.ikiwiki.info.git] / IkiWiki / Plugin / meta.pm
index cd6fa20bab87e3d74a0480e4eefaee08bbd74e2b..b19ea2b3294b0e1c985c56162084b5e2430d6398 100644 (file)
@@ -217,6 +217,13 @@ sub preprocess (@) {
                                'content="'.encode_entities($url).'" />';
                }
        }
                                'content="'.encode_entities($url).'" />';
                }
        }
+       elsif ($key eq 'foaf') {
+               if (safeurl($value)) {
+                       push @{$metaheaders{$page}}, '<link rel="meta" '.
+                               'type="application/rdf+xml" title="FOAF" '.
+                               'href="'.encode_entities($value).'" />';
+               }
+       }
        elsif ($key eq 'redir') {
                return "" if $page ne $destpage;
                my $safe=0;
        elsif ($key eq 'redir') {
                return "" if $page ne $destpage;
                my $safe=0;
@@ -268,17 +275,23 @@ sub preprocess (@) {
                push @{$metaheaders{$page}}, '<meta name="robots"'.
                        ' content="'.encode_entities($value).'" />';
        }
                push @{$metaheaders{$page}}, '<meta name="robots"'.
                        ' content="'.encode_entities($value).'" />';
        }
-       elsif ($key eq 'description') {
-               push @{$metaheaders{$page}}, '<meta name="'.
-                       encode_entities($key).
+       elsif ($key eq 'description' || $key eq 'author') {
+               push @{$metaheaders{$page}}, '<meta name="'.$key.
                        '" content="'.encode_entities($value).'" />';
        }
        elsif ($key eq 'name') {
                        '" content="'.encode_entities($value).'" />';
        }
        elsif ($key eq 'name') {
-               push @{$metaheaders{$page}}, scrub('<meta '.$key.'="'.
+               push @{$metaheaders{$page}}, scrub('<meta name="'.
                        encode_entities($value).
                        join(' ', map { "$_=\"$params{$_}\"" } keys %params).
                        ' />', $page, $destpage);
        }
                        encode_entities($value).
                        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="'.
        else {
                push @{$metaheaders{$page}}, scrub('<meta name="'.
                        encode_entities($key).'" content="'.
@@ -301,23 +314,25 @@ sub pagetemplate (@) {
        }
        if (exists $pagestate{$page}{meta}{title} && $template->query(name => "title")) {
                eval q{use HTML::Entities};
        }
        if (exists $pagestate{$page}{meta}{title} && $template->query(name => "title")) {
                eval q{use HTML::Entities};
-               $template->param(title => encode_numeric($pagestate{$page}{meta}{title}));
+               $template->param(title => HTML::Entities::encode_numeric($pagestate{$page}{meta}{title}));
                $template->param(title_overridden => 1);
        }
 
                $template->param(title_overridden => 1);
        }
 
-       foreach my $field (qw{author authorurl permalink}) {
+       foreach my $field (qw{author authorurl}) {
                $template->param($field => $pagestate{$page}{meta}{$field})
                        if exists $pagestate{$page}{meta}{$field} && $template->query(name => $field);
        }
 
        foreach my $field (qw{permalink}) {
                $template->param($field => $pagestate{$page}{meta}{$field})
                        if exists $pagestate{$page}{meta}{$field} && $template->query(name => $field);
        }
 
        foreach my $field (qw{permalink}) {
-               $template->param($field => IkiWiki::urlabs($pagestate{$page}{meta}{$field}, $config{url}))
-                       if exists $pagestate{$page}{meta}{$field} && $template->query(name => $field);
+               if (exists $pagestate{$page}{meta}{$field} && $template->query(name => $field)) {
+                       eval q{use HTML::Entities};
+                       $template->param($field => HTML::Entities::encode_entities(IkiWiki::urlabs($pagestate{$page}{meta}{$field}, $config{url})));
+               }
        }
 
        foreach my $field (qw{description}) {
                eval q{use HTML::Entities};
        }
 
        foreach my $field (qw{description}) {
                eval q{use HTML::Entities};
-               $template->param($field => encode_numeric($pagestate{$page}{meta}{$field}))
+               $template->param($field => HTML::Entities::encode_numeric($pagestate{$page}{meta}{$field}))
                        if exists $pagestate{$page}{meta}{$field} && $template->query(name => $field);
        }
 
                        if exists $pagestate{$page}{meta}{$field} && $template->query(name => $field);
        }