]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/img.pm
rename comments_form to editcomment
[ikiwiki.git] / IkiWiki / Plugin / img.pm
index 66cc08530e685e8d10f6ae90646d7496a00401d2..395890c0e1bcafdebc1ff4b84082026a634b42a0 100644 (file)
@@ -9,20 +9,20 @@ use IkiWiki 2.00;
 
 my %imgdefaults;
 
-sub import { #{{{
+sub import {
        hook(type => "getsetup", id => "img", call => \&getsetup);
        hook(type => "preprocess", id => "img", call => \&preprocess, scan => 1);
-} #}}}
+}
 
-sub getsetup () { #{{{
+sub getsetup () {
        return
                plugin => {
                        safe => 1,
                        rebuild => undef,
                },
-} #}}}
+}
 
-sub preprocess (@) { #{{{
+sub preprocess (@) {
        my ($image) = $_[0] =~ /$config{wiki_file_regexp}/; # untaint
        my %params=@_;
 
@@ -65,9 +65,10 @@ sub preprocess (@) { #{{{
        my $r;
 
        if ($params{size} ne 'full') {
-               my ($w, $h) = ($params{size} =~ /^(\d+)x(\d+)$/);
+               my ($w, $h) = ($params{size} =~ /^(\d*)x(\d*)$/);
                error sprintf(gettext('bad size "%s"'), $params{size})
-                       unless (defined $w && defined $h);
+                       unless (defined $w && defined $h &&
+                               (length $w || length $h));
 
                my $outfile = "$config{destdir}/$dir/${w}x${h}-$base";
                $imglink = "$dir/${w}x${h}-$base";
@@ -148,6 +149,6 @@ sub preprocess (@) { #{{{
        else {
                return $imgtag;
        }
-} #}}}
+}
 
 1