X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/6f46cc3b3134e947bb2c5f1ae7dfdd85c9d9dc0c..6d98c5290f2542552979e374d8e3dcbef51f31a6:/IkiWiki/Plugin/progress.pm?ds=sidebyside diff --git a/IkiWiki/Plugin/progress.pm b/IkiWiki/Plugin/progress.pm index e459637b8..e536f4e23 100644 --- a/IkiWiki/Plugin/progress.pm +++ b/IkiWiki/Plugin/progress.pm @@ -5,7 +5,7 @@ use warnings; use strict; use IkiWiki 2.00; -my $percentage_pattern = qr/[0-9]+\%/; # pattern to validate percentages +my $percentage_pattern = qr/[0-9]+\%?/; # pattern to validate percentages sub import { #{{{ hook(type => "getsetup", id => "progress", call => \&getsetup); @@ -29,6 +29,11 @@ sub preprocess (@) { #{{{ if (defined $params{percent}) { $fill = $params{percent}; ($fill) = $fill =~ m/($percentage_pattern)/; # fill is untainted now + $fill=~s/%$//; + if (! defined $fill || ! length $fill || $fill > 100 || $fill < 0) { + error(sprintf(gettext("illegal percent value %s"), $params{percent})); + } + $fill.="%"; } elsif (defined $params{totalpages} and defined $params{donepages}) { add_depends($params{page}, $params{totalpages}); @@ -51,7 +56,7 @@ sub preprocess (@) { #{{{ } } else { - error("need either `percent` or `totalpages` and `donepages` parameters"); + error(gettext("need either `percent` or `totalpages` and `donepages` parameters")); } return <