diff options
author | Joey Hess <joey@kitenet.net> | 2011-06-14 15:47:47 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-06-14 15:49:33 -0400 |
commit | 2e086b3263f33d3d42ddbcb451e9995c466929cd (patch) | |
tree | 1b1eda1efcc486878eda32578753e408b2172b04 /IkiWiki | |
parent | d4254c7f97cacffe500c3a9b6c1d887ebd3687fb (diff) | |
download | ikiwiki-2e086b3263f33d3d42ddbcb451e9995c466929cd.tar ikiwiki-2e086b3263f33d3d42ddbcb451e9995c466929cd.tar.gz |
remove trailing slash from attachment_holding_dir
If it's passed a filename, it should return the filename inside the holding
dir. If passed a page, the directory sans slash. All code adds the slash.
Diffstat (limited to 'IkiWiki')
-rw-r--r-- | IkiWiki/Plugin/attachment.pm | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/IkiWiki/Plugin/attachment.pm b/IkiWiki/Plugin/attachment.pm index f8a3a68c6..4bd08bf7b 100644 --- a/IkiWiki/Plugin/attachment.pm +++ b/IkiWiki/Plugin/attachment.pm @@ -153,18 +153,19 @@ sub formbuilder (@) { $form->tmpl_param("attachment_list" => [attachment_list($form->field('page'))]); } -sub attachment_holding_dir { +sub attachment_holding_location { my $page=attachment_location(shift); - return $config{wikistatedir}."/attachments/". + my $dir=$config{wikistatedir}."/attachments/". IkiWiki::possibly_foolish_untaint(linkpage($page)); + $dir=~s/\/$//; + return $dir; } sub is_held_attachment { my $attachment=shift; - my $f=attachment_holding_dir($attachment); - $f=~s/\/$//; + my $f=attachment_holding_location($attachment); if (-f $f) { return $f } @@ -214,7 +215,7 @@ sub attachment_store { # Move the attachment into holding directory. # Try to use a fast rename; fall back to copying. - my $dest=attachment_holding_dir($form->field('page')); + my $dest=attachment_holding_location($form->field('page')); IkiWiki::prep_writefile($filename, $dest); unlink($dest."/".$filename); if (rename($tempfile, $dest."/".$filename)) { @@ -248,7 +249,7 @@ sub attachments_save { # Move attachments out of holding directory. my @attachments; - my $dir=attachment_holding_dir($form->field('page')); + my $dir=attachment_holding_location($form->field('page')); foreach my $filename (glob("$dir/*")) { next unless -f $filename; my $dest=$config{srcdir}."/". @@ -317,7 +318,7 @@ sub attachment_list ($) { } # attachments in holding directory - my $dir=attachment_holding_dir($page); + my $dir=attachment_holding_location($page); my $heldmsg=gettext("this attachment is not yet saved"); foreach my $file (glob("$dir/*")) { next unless -f $file; |