diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index b047f2aa7..ae215a18f 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -13,6 +13,7 @@ - fixed #11177: Code editor steals focus on load - fixed #10888: Final touches on map point bugs - fixed #11274: Add attachment broken in template + - fixed #11272: Security issue with asset manager search 7.8.5 - added the EMS submission subsystem diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 92cd19163..969d5e4ae 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -1402,6 +1402,21 @@ sub getRoot { } +#------------------------------------------------------------------- + +=head2 getSearchUrl ( ) + +Returns the URL for the search screen of the asset manager. + +=cut + +sub getSearchUrl { + my $self = shift; + return $self->getUrl( 'op=assetManager;method=search' ); +} + + + #------------------------------------------------------------------- =head2 getSeparator @@ -2891,8 +2906,7 @@ sub www_editSave { =head2 www_manageAssets ( ) -Redirect to the asset manager content handler (for backwards -compatibility) +Redirect to the asset manager content handler (for backwards compatibility) =cut @@ -2904,6 +2918,21 @@ sub www_manageAssets { #------------------------------------------------------------------- +=head2 www_searchAssets ( ) + +Redirect to the asset manager content handler (for backwards +compatibility) + +=cut + +sub www_searchAssets { + my $self = shift; + $self->session->http->setRedirect( $self->getSearchUrl ); + return "redirect"; +} + +#------------------------------------------------------------------- + =head2 www_view ( ) Returns the view() method of the asset object if the requestor canView. diff --git a/lib/WebGUI/Content/AssetManager.pm b/lib/WebGUI/Content/AssetManager.pm index 005d6bab2..9c0c58a59 100644 --- a/lib/WebGUI/Content/AssetManager.pm +++ b/lib/WebGUI/Content/AssetManager.pm @@ -19,17 +19,20 @@ Gets a select box to choose a class name. sub getClassSelectBox { my $session = shift; + my $i18n = WebGUI::International->new($session, 'Asset'); tie my %classes, "Tie::IxHash", ( - "" => "Any Class", + "" => $i18n->get("Any Class"), $session->db->buildHash("select distinct(className) from asset"), ); delete $classes{"WebGUI::Asset"}; # don't want to search for the root asset + my $className = $session->scratch->get('assetManagerSearchClassName') || $session->form->process("class","className"); + $session->scratch->set('assetManagerSearchClassName', $className); return WebGUI::Form::selectBox( $session, { - name => "class", - value => $session->form->process("class","className"), - defaultValue => "", + name => "class", + value => $className, + defaultValue => "", options => \%classes, }); } @@ -142,8 +145,10 @@ sub getSearchPaginator { $queryString .= ';class=' . $class; } - my $p = $s->getPaginatorResultSet( $session->url->page( $queryString ) ); + my $pageNumber = $session->scratch->get('assetManagerSearchPageNumber') || $session->form->get('pn'); + my $p = $s->getPaginatorResultSet( $session->url->page( $queryString ), undef, $pageNumber ); + $session->scratch->set('assetManagerSearchPageNumber', $pageNumber); return $p; } @@ -533,64 +538,36 @@ sub www_search { $session->style->setScript( $session->url->extras( 'yui/build/yahoo-dom-event/yahoo-dom-event.js' ) ); $session->style->setScript( $session->url->extras( 'yui-webgui/build/assetManager/assetManager.js' ) ); $session->style->setScript( $session->url->extras( 'yui-webgui/build/form/form.js' ) ); + my $keywords = $session->scratch->get('assetManagerSearchKeywords') || $session->form->get('keywords'); ### Show the form $output .= q{
} ; - ### Actions - if ( my $action = lc $session->form->get( 'action' ) ) { - my @assetIds = $session->form->get( 'assetId' ); - - if ( $action eq "delete" ) { ##aka trash - for my $assetId ( @assetIds ) { - my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId ); - next unless $asset; - $asset->trash; - } - } - elsif ( $action eq "cut" ) { - for my $assetId ( @assetIds ) { - my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId ); - next unless $asset; - $asset->cut; - } - } - elsif ( $action eq "copy" ) { - for my $assetId ( @assetIds ) { - # Copy == Duplicate + Cut - my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId); - my $newAsset = $asset->duplicate( { skipAutoCommitWorkflows => 1 } ); - $newAsset->update( { title => $newAsset->getTitle . ' (copy)' } ); - $newAsset->cut; - } - } - } - ### Run the search - if ( $session->form->get( 'keywords' ) || $session->form->get( 'class' ) ) { - my $keywords = $session->form->get( 'keywords' ); - my @classes = $session->form->get( 'class' ); + if ( $keywords || $session->form->get( 'class' ) ) { + my @classes = $session->form->get( 'class' ); + my $keywordsScrubbed = $keywords; # Detect a helper word key my @assetIds = ($keywords =~ /assetid:\s*([^\s]+)/gi); # purge helper word keys if (@assetIds) { - $keywords =~ s/\bassetid:\s*[^\s]+//gi; + $keywordsScrubbed =~ s/\bassetid:\s*[^\s]+//gi; } - $keywords =~ s/^\s+//g; - $keywords =~ s/\s+$//g; + $keywordsScrubbed =~ s/^\s+//g; + $keywordsScrubbed =~ s/\s+$//g; my $p = getSearchPaginator( $session, { assetIds => \@assetIds, - keywords => $keywords, + keywords => $keywordsScrubbed, classes => \@classes, orderByColumn => $session->form->get( 'orderByColumn' ), orderByDirection => $session->form->get( 'orderByDirection' ), @@ -601,9 +578,10 @@ sub www_search { } else { ### Display the search results - $output .= q{} ; @@ -730,6 +708,7 @@ sub www_search { $output .= ''; + $session->scratch->set('assetManagerSearchKeywords', $keywords); return $ac->render( $output ); } diff --git a/lib/WebGUI/i18n/English/Asset.pm b/lib/WebGUI/i18n/English/Asset.pm index 708f23973..5ad1ec7e6 100644 --- a/lib/WebGUI/i18n/English/Asset.pm +++ b/lib/WebGUI/i18n/English/Asset.pm @@ -1392,6 +1392,12 @@ Couldn't open %-s because %-s