From 1131a5b4bc45486df780b0efae538fe5cf2a2ecd Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Tue, 14 Sep 2010 10:01:57 -0700 Subject: [PATCH] Ignore trailing slashes in requested URLS. Fixes bug #11865. --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Content/Asset.pm | 1 + t/Content/Asset.t | 12 ++++++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index f88d18483..edaca3695 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -5,6 +5,7 @@ - fixed #11833: Recheck for losing Product Images - fixed #11788: Calendar - Can't enter Midnight - Broke page layout - fixed #11855: Purging Shortcut from Trash causes loop + - fixed #11865: URL with slash no longer works. 7.10.0 - fixed #11812: Checking www_ajaxSave's response in the cart js, urlencoding post parameters diff --git a/lib/WebGUI/Content/Asset.pm b/lib/WebGUI/Content/Asset.pm index 58598099e..5e429267a 100644 --- a/lib/WebGUI/Content/Asset.pm +++ b/lib/WebGUI/Content/Asset.pm @@ -63,6 +63,7 @@ The URL for this request. sub dispatch { my $session = shift; my $assetUrl = shift; + $assetUrl =~ s{/$}{}; my $permutations = getUrlPermutations($assetUrl); foreach my $url (@{ $permutations }) { if (my $asset = getAsset($session, $url)) { diff --git a/t/Content/Asset.t b/t/Content/Asset.t index beccd90e5..a515d9970 100644 --- a/t/Content/Asset.t +++ b/t/Content/Asset.t @@ -93,7 +93,7 @@ WebGUI::Test->addToCleanup( WebGUI::VersionTag->getWorking( $session ) ); #---------------------------------------------------------------------------- # Tests -plan tests => 23; # Increment this number for each test you create +plan tests => 25; # Increment this number for each test you create #---------------------------------------------------------------------------- # test getUrlPermutation( url ) method @@ -138,15 +138,23 @@ cmp_deeply( [ $utf8_url ], "UTF-8 handling for URLs", ); +cmp_deeply( + WebGUI::Content::Asset::getUrlPermutations( "/one/two/three/" ), + [ '/one/two/three', '/one/two', '/one', ], + "trailing slashes are ignored", +); #---------------------------------------------------------------------------- # test dispatch( session, url ) method is ($session->asset, undef, 'session asset is not defined, yet'); $output = WebGUI::Content::Asset::dispatch( $session, "testdispatch" ); is $output, "www_view one", "Regular www_view"; - is $session->asset && $session->asset->getId, $td->getId, 'dispatch set the session asset'; +$output = WebGUI::Content::Asset::dispatch( $session, "testdispatch/" ); +is $output, "www_view one", "trailing slashes are ignored"; + + my $_asset = WebGUI::Asset->newByUrl($session, $utf8_url); isa_ok $_asset, 'WebGUI::Asset::TestDispatch';