From 3b577599f53702a090a7d1fbf83a89bb4b3de044 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Wed, 5 Aug 2009 22:16:38 +0000 Subject: [PATCH] Forward port XML encoding for template based RSS feeds in the Gallery. --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Asset/Wobject/Gallery.pm | 8 +++++++- lib/WebGUI/Asset/Wobject/GalleryAlbum.pm | 14 ++++++++++++-- t/Asset/Wobject/Gallery/permission.t | 7 +------ t/Asset/Wobject/GalleryAlbum/edit.t | 10 ++-------- t/Asset/Wobject/GalleryAlbum/rss.t | 13 ++++++------- 6 files changed, 29 insertions(+), 24 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 54a912bb0..e2786e253 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -27,6 +27,7 @@ - fixed #10721: Invalid/Missing Style TemplateIds in use - fixed #10029: Account CSS rule scoping - fixed #10641: Matrix Asset - Compare/Search buttons broken in Opera + - fixed #10723: RSS Feed Error in Gallery 7.7.16 - fixed #10590: Session::DateTime->secondsToInterval doesn't allow 7 weeks diff --git a/lib/WebGUI/Asset/Wobject/Gallery.pm b/lib/WebGUI/Asset/Wobject/Gallery.pm index 941f74af7..8b24fe7d8 100644 --- a/lib/WebGUI/Asset/Wobject/Gallery.pm +++ b/lib/WebGUI/Asset/Wobject/Gallery.pm @@ -18,6 +18,7 @@ use Tie::IxHash; use WebGUI::International; use WebGUI::Utility; use XML::Simple; +use WebGUI::HTML; =head1 NAME @@ -1212,7 +1213,12 @@ sub www_listAlbumsRss { for my $key ( qw( url ) ) { $assetVar->{ $key } = $self->session->url->getSiteURL . $assetVar->{ $key }; } - + + # Encode XML entities + for my $key ( qw( title description synopsis gallery_title gallery_menuTitle ) ) { + $assetVar->{ $key } = WebGUI::HTML::filter($assetVar->{$key}, 'xml'); + } + # Additional vars for RSS $assetVar->{ rssDate } = $session->datetime->epochToMail( $assetVar->{ creationDate } ); diff --git a/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm b/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm index 8413e2293..b8f8e90a3 100644 --- a/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm +++ b/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm @@ -20,6 +20,7 @@ use File::Temp qw{ tempdir }; use Tie::IxHash; use WebGUI::International; use WebGUI::Utility; +use WebGUI::HTML; use Archive::Any; @@ -1069,7 +1070,7 @@ sub www_addFileService { # my $filePath = $storage->getPath( $storage->getFiles->[0] ); # $self->setFile( $filePath ); # $storage->delete; - $session->log->warn('XX:'. $filename); + #$session->log->warn('XX:'. $filename); $file->requestAutoCommit; @@ -1413,18 +1414,27 @@ sub www_viewRss { my $var = $self->getTemplateVars; $self->appendTemplateVarsFileLoop( $var, $self->getFileIds ); - + # Fix URLs to be full URLs for my $key ( qw( url url_viewRss ) ) { $var->{ $key } = $self->session->url->getSiteURL . $var->{ $key }; } + # Encode XML entities + for my $key ( qw( title description synopsis gallery_title gallery_menuTitle ) ) { + $var->{ $key } = WebGUI::HTML::filter($var->{$key}, 'xml'); + } + # Process the file loop to add additional params for my $file ( @{ $var->{file_loop} } ) { # Fix URLs to be full URLs for my $key ( qw( url ) ) { $file->{ $key } = $self->session->url->getSiteURL . $file->{$key}; } + # Encode XML entities + for my $key ( qw( title description synopsis ) ) { + $file->{ $key } = WebGUI::HTML::filter($file->{$key}, 'xml'); + } $file->{ rssDate } = $self->session->datetime->epochToMail( $file->{creationDate} ); diff --git a/t/Asset/Wobject/Gallery/permission.t b/t/Asset/Wobject/Gallery/permission.t index 4b039c334..7b07921d5 100644 --- a/t/Asset/Wobject/Gallery/permission.t +++ b/t/Asset/Wobject/Gallery/permission.t @@ -25,6 +25,7 @@ my $session = WebGUI::Test->session; my $node = WebGUI::Asset->getImportNode($session); my $versionTag = WebGUI::VersionTag->getWorking($session); $versionTag->set({name=>"Gallery Test"}); +WebGUI::Test->tagsToRollback($versionTag); my $maker = WebGUI::Test::Maker::Permission->new; my $gallery; @@ -75,9 +76,3 @@ $maker->prepare( plan tests => $maker->plan; $maker->run; - -#---------------------------------------------------------------------------- -# Cleanup -END { - $versionTag->rollback; -} diff --git a/t/Asset/Wobject/GalleryAlbum/edit.t b/t/Asset/Wobject/GalleryAlbum/edit.t index 1d6ddf475..b250ac53a 100644 --- a/t/Asset/Wobject/GalleryAlbum/edit.t +++ b/t/Asset/Wobject/GalleryAlbum/edit.t @@ -20,6 +20,7 @@ use Test::More; use WebGUI::Test; # Must use this before any other WebGUI modules use WebGUI::Session; use Test::Deep; +plan skip_all => 'set WEBGUI_LIVE to enable this test' unless $ENV{WEBGUI_LIVE}; #---------------------------------------------------------------------------- # Init @@ -58,6 +59,7 @@ my $gallery } ); $versionTags[-1]->commit; +WebGUI::Test->tagsToRollback(@versionTags); #---------------------------------------------------------------------------- # Tests @@ -110,14 +112,6 @@ $mech->content_contains( my $album = WebGUI::Asset->newByDynamicClass( $session, $gallery->getAlbumIds->[0] ); cmp_deeply( $properties, subhashof( $album->get ), "Properties from edit form are set correctly" ); -#---------------------------------------------------------------------------- -# Cleanup -END { - for my $tag ( @versionTags ) { - $tag->rollback; - } -} - #---------------------------------------------------------------------------- # getMechLogin( baseUrl, WebGUI::User, "identifier" ) # Returns a Test::WWW::Mechanize session after logging in the given user using diff --git a/t/Asset/Wobject/GalleryAlbum/rss.t b/t/Asset/Wobject/GalleryAlbum/rss.t index 66d80c31a..47337bbc3 100644 --- a/t/Asset/Wobject/GalleryAlbum/rss.t +++ b/t/Asset/Wobject/GalleryAlbum/rss.t @@ -20,6 +20,7 @@ use WebGUI::Session; use Test::More; use Test::Deep; use XML::Simple; +plan skip_all => 'set WEBGUI_LIVE to enable this test' unless $ENV{WEBGUI_LIVE}; #---------------------------------------------------------------------------- # Init @@ -27,6 +28,7 @@ my $session = WebGUI::Test->session; my $node = WebGUI::Asset->getImportNode($session); my $versionTag = WebGUI::VersionTag->getWorking($session); $versionTag->set({name=>"Album Test"}); +WebGUI::Test->tagsToRollback($versionTag); my $gallery = $node->addChild({ className => "WebGUI::Asset::Wobject::Gallery", @@ -40,13 +42,16 @@ my $album = $gallery->addChild({ className => "WebGUI::Asset::Wobject::GalleryAlbum", ownerUserId => "3", # Admin - description => "An RSS Description", + description => "An RSS Description with an extra  space", + title => "Title with extra  dash", }, undef, undef, { skipAutoCommitWorkflows => 1, }); +diag $album->get('title'); +diag $album->get('description'); my @photos; for my $i ( 0 .. 5 ) { $photos[ $i ] @@ -114,9 +119,3 @@ cmp_deeply( }, "RSS Datastructure is complete and correct", ); - -#---------------------------------------------------------------------------- -# Cleanup -END { - $versionTag->rollback(); -}