progress: Display an error if the progress cannot be parsed, and allow the percent parameter to only optionally end with "%".
parent
cc3b946c8f
commit
779c5214f3
|
@ -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});
|
||||
|
|
|
@ -5,6 +5,8 @@ ikiwiki (2.65) UNRELEASED; urgency=low
|
|||
* editdiff: Broken since 2.62 due to wrong syntax, now fixed.
|
||||
* aggregate: Support atom feeds with only a summary element, and no content
|
||||
elements.
|
||||
* progress: Display an error if the progress cannot be parsed, and allow
|
||||
the percent parameter to only optionally end with "%".
|
||||
|
||||
-- Joey Hess <joeyh@debian.org> Wed, 17 Sep 2008 14:26:56 -0400
|
||||
|
||||
|
|
|
@ -27,6 +27,11 @@ Anyone can confirm the bug? --[[Paweł|ptecza]]
|
|||
>> that '%' sign is confusing here and should be dropped. I hope it's clear for all
|
||||
>> people that "percent" parameter passes values in percentages. --[[Paweł|ptecza]]
|
||||
|
||||
>>> [[fixed|done]] --[[Joey]]
|
||||
|
||||
>>> I've forgotten to add that now the HTML code is OK, but I can see only
|
||||
>>> "75%" string on white background wihout any border. I need to look closer
|
||||
>>> at CSS styles for the progress bar. --[[Paweł|ptecza]]
|
||||
|
||||
>>>> You need the `div.progress` and `div.progress-done` from ikiwiki's
|
||||
>>>> default `style.css`. --[[Joey]]
|
||||
|
|
Loading…
Reference in New Issue