Skip to content

Commit

Permalink
Item14055: recalculate filesize after beforeUploadHandler
Browse files Browse the repository at this point in the history
Plugins can modify the file/stream's content of uploaded/attached
files(according to the API docu in Foswiki::Plugins::EmptyPlugin).
Hence, we need to recalculate the filesize after the handler(s)
have been called.
  • Loading branch information
Philippe Kehl authored and gac410 committed Apr 24, 2016
1 parent 4aac8f3 commit 2eb062b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/lib/Foswiki/Meta.pm
Expand Up @@ -2946,6 +2946,11 @@ sub attach {
seek( $opts{stream}, 0, 0 ); # seek to beginning
binmode( $opts{stream} );

# recalculate filesize as beforeUploadHandler may have modified the content
if (defined $opts{filesize}) {
$opts{filesize} = (stat($attrs->{stream}))[7];
}

$handlers_called = 1;
}

Expand Down

0 comments on commit 2eb062b

Please sign in to comment.