]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/fortune.pm
Add automated test for using the CGI with git, including CVE-2016-10026
[git.ikiwiki.info.git] / IkiWiki / Plugin / fortune.pm
1 #!/usr/bin/perl
2 # Include a fortune in a page
3 package IkiWiki::Plugin::fortune;
5 use warnings;
6 use strict;
7 use IkiWiki 3.00;
9 sub import {
10         hook(type => "getsetup", id => "fortune", call => \&getsetup);
11         hook(type => "preprocess", id => "fortune", call => \&preprocess);
12 }
14 sub getsetup () {
15         return
16                 plugin => {
17                         safe => 1,
18                         rebuild => undef,
19                         section => "widget",
20                 },
21 }
23 sub preprocess (@) {
24         $ENV{PATH}="$ENV{PATH}:/usr/games:/usr/local/games";
25         my $f = `fortune 2>/dev/null`;
27         if ($?) {
28                 error gettext("fortune failed");
29         }
30         else {
31                 return "<pre>$f</pre>\n";
32         }
33 }
35 1