aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/progress.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-09-19 13:09:50 -0400
committerJoey Hess <joey@kodama.kitenet.net>2008-09-19 13:09:50 -0400
commit779c5214f330269fa95a5fed5b16fe8d65730102 (patch)
treea649d671b65f0e536c36dca1a81a000792f3b0fd /IkiWiki/Plugin/progress.pm
parentcc3b946c8f31b604774f2bb40a0d24b2c463f62c (diff)
downloadikiwiki-779c5214f330269fa95a5fed5b16fe8d65730102.tar
ikiwiki-779c5214f330269fa95a5fed5b16fe8d65730102.tar.gz
progress: Display an error if the progress cannot be parsed, and allow the percent parameter to only optionally end with "%".
Diffstat (limited to 'IkiWiki/Plugin/progress.pm')
-rw-r--r--IkiWiki/Plugin/progress.pm8
1 files changed, 7 insertions, 1 deletions
diff --git a/IkiWiki/Plugin/progress.pm b/IkiWiki/Plugin/progress.pm
index e459637b8..6cb21a916 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,12 @@ sub preprocess (@) { #{{{
if (defined $params{percent}) {
$fill = $params{percent};
($fill) = $fill =~ m/($percentage_pattern)/; # fill is untainted now
+ if (! defined $fill || ! length $fill || $fill > 100 || $fill < 0) {
+ error("illegal percent value $params{percent}");
+ }
+ elsif ($fill !~ /%$/) {
+ $fill.="%";
+ }
}
elsif (defined $params{totalpages} and defined $params{donepages}) {
add_depends($params{page}, $params{totalpages});