From 72906e27fb0975d0ba86641fa6489d56af3db4aa Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Tue, 4 Dec 2007 21:25:32 +0000 Subject: [PATCH] fixing handling of http:// calls in the Extras URL --- docs/changelog/7.x.x.txt | 2 ++ lib/WebGUI/Session/Url.pm | 14 ++++++++------ t/Session/Url.t | 22 +++++++++++++++++----- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 2706a633b..07c56d806 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -11,6 +11,8 @@ 7.4.17 - fix: double width characters encoded incorrectly in Collaboration RSS feed + - fix: ExtrasUrl in conf http:// stripping / from URL (perlDreamer Consulting, LLC.) + http://www.plainblack.com/bugs/tracker/extrasurl-in-conf-http/-stripping-/-from-url 7.4.16 - fix: Event End Time Missing (perlDreamer Consulting, LLC.) diff --git a/lib/WebGUI/Session/Url.pm b/lib/WebGUI/Session/Url.pm index 0d45d8e72..8cc92c58f 100644 --- a/lib/WebGUI/Session/Url.pm +++ b/lib/WebGUI/Session/Url.pm @@ -130,16 +130,18 @@ Combinds the base extrasURL defined in the config file with a specfied path. =head3 path -The path to the thing in the extras folder that you're referencing. Note that the leading / is not necessary. Multiple consecutive slashes will be replaced with a single slash. +The path to the thing in the extras folder that you're +referencing. Note that the leading / is not necessary. Multiple +consecutive slashes in the path part of the URL will be replaced with a single slash. =cut sub extras { - my $self = shift; - my $path = shift; - my $url = $self->session->config->get("extrasURL").'/'.$path; - $url =~ s!/+!/!g; - return $url; + my $self = shift; + my $path = shift; + my $url = $self->session->config->get("extrasURL").'/'.$path; + $url =~ s$(? 56 + scalar(@getRefererUrlTests); +plan tests => 58 + scalar(@getRefererUrlTests); my $session = WebGUI::Test->session; @@ -278,10 +278,21 @@ is($session->url->makeAbsolute('page1'), '/page1', 'makeAbsolute: default baseUr # ####################################### -is($session->url->extras, $session->config->get('extrasURL').'/', 'extras method returns URL to extras with a trailing slash'); -is($session->url->extras('foo.html'), join('/', $session->config->get('extrasURL'),'foo.html'), 'extras method appends to the extras url'); -is($session->url->extras('/foo.html'), join('/', $session->config->get('extrasURL'),'foo.html'), 'extras method removes extra slashes'); -is($session->url->extras('/dir1//foo.html'), join('/', $session->config->get('extrasURL'),'dir1/foo.html'), 'extras method removes extra slashes anywhere'); +my $origExtras = $session->config->get('extrasURL'); +my $extras = $origExtras; + +is($session->url->extras, $extras.'/', 'extras method returns URL to extras with a trailing slash'); +is($session->url->extras('foo.html'), join('/', $extras,'foo.html'), 'extras method appends to the extras url'); +is($session->url->extras('/foo.html'), join('/', $extras,'foo.html'), 'extras method removes extra slashes'); +is($session->url->extras('/dir1//foo.html'), join('/', $extras,'dir1/foo.html'), 'extras method removes extra slashes anywhere'); + +$extras = 'http://mydomain.com/'; +$session->config->set('extrasURL', $extras); + +is($session->url->extras('/foo.html'), join('', $extras,'foo.html'), 'extras method removes extra slashes'); +is($session->url->extras('/dir1//foo.html'), join('', $extras,'dir1/foo.html'), 'extras method removes extra slashes anywhere'); + +$session->config->set('extrasURL', $origExtras); ####################################### # @@ -387,6 +398,7 @@ END { ##Always clean-up $session->setting->set('hostToUse', $setting_hostToUse); $session->setting->set('preventProxyCache', $preventProxyCache); $session->config->set('gateway', $gateway); + $session->config->set('extrasURL', $origExtras); if ($config_port) { $session->config->set($config_port);