From 980dc18831b388dab777ecb83975d3dd6abd912d Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Mon, 11 Aug 2008 20:18:31 +0000 Subject: [PATCH] fixed: Gallery now gives an error message when a Zip archive is being naughty --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Asset/Wobject/GalleryAlbum.pm | 9 +++++++-- lib/WebGUI/i18n/English/Asset_GalleryAlbum.pm | 6 ++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 3db071e8b..ce6caeccb 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -13,6 +13,7 @@ - fixed: Gallery navigation back to album returns to page 1 (Martin Kamerbeek / Oqapi) - fixed: WSClient now correctly handles SOAP::Som returns of simple arrays of scalars and a exception producing if test turned into an eval. + - fixed: Gallery now gives an error message when a Zip archive is being naughty 7.5.19 - fixed: paginator doesn't show correct number of page links with a limit applied diff --git a/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm b/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm index 53bd144ce..1e579ea2a 100644 --- a/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm +++ b/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm @@ -103,7 +103,7 @@ sub addArchive { my $archive = Archive::Any->new( $filename ); - croak "Archive will extract to directory outside of storage location!" + die "Archive will extract to directory outside of storage location!\n" if $archive->is_naughty; my $tempdirName = tempdir( "WebGUI-Gallery-XXXXXXXX", TMPDIR => 1, CLEANUP => 1); @@ -882,7 +882,12 @@ sub www_addArchiveSave { } my $filename = $storage->getPath( $storage->getFiles->[0] ); - $self->addArchive( $filename, $properties ); + eval { $self->addArchive( $filename, $properties ) }; + if ( my $error = $@ ) { + return $self->www_addArchive({ + error => sprintf( $i18n->get('addArchive error generic'), $error ), + }); + } $storage->delete; diff --git a/lib/WebGUI/i18n/English/Asset_GalleryAlbum.pm b/lib/WebGUI/i18n/English/Asset_GalleryAlbum.pm index 5688275ac..a4818f8cb 100644 --- a/lib/WebGUI/i18n/English/Asset_GalleryAlbum.pm +++ b/lib/WebGUI/i18n/English/Asset_GalleryAlbum.pm @@ -311,6 +311,12 @@ our $I18N = { lastUpdated => 0, }, + 'addArchive error generic' => { + message => 'There was an error uploading your archive: %s', + lastUpdated => 0, + context => 'Lead in to an error message from WebGUI', + }, + 'template url_addPhoto' => { message => 'Add a Photo', lastUpdated => 0,