From 0d1d2a467510b0a05638d5711373a713f9905886 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Sat, 10 Jun 2006 16:34:59 +0000 Subject: [PATCH] fix HttpProxy turns ampersands into semicolons --- docs/changelog/6.x.x.txt | 2 ++ docs/upgrades/upgrade_6.99.3-6.99.4.pl | 17 ++++++++++++++ lib/WebGUI/Asset/Wobject/HttpProxy.pm | 27 +++++++++++++++++++++- lib/WebGUI/Help/Asset_HttpProxy.pm | 5 ++++ lib/WebGUI/i18n/English/Asset_HttpProxy.pm | 12 ++++++++++ 5 files changed, 62 insertions(+), 1 deletion(-) diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index 399378854..7125b5cc7 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -21,6 +21,8 @@ - fix: op=saveSettings broken - fix: EMS Discount Pass Not Applied - fix: Commerce checkout confirmation very confusing + - fix: HttpProxy turns ampersands into semicolons + 6.99.3 - Someone removed the status from the submission templates. That has been diff --git a/docs/upgrades/upgrade_6.99.3-6.99.4.pl b/docs/upgrades/upgrade_6.99.3-6.99.4.pl index b44631cb4..76c875ee1 100644 --- a/docs/upgrades/upgrade_6.99.3-6.99.4.pl +++ b/docs/upgrades/upgrade_6.99.3-6.99.4.pl @@ -24,9 +24,26 @@ my $session = start(); # this line required fixSurvey($session); fixEditWorkflow($session); +fixOrphans(); +updateHttpProxy(); finish($session); # this line required +#------------------------------------------------- +sub updateHttpProxy { + print "\tAllowing HTTP Proxy to use ampersands in addition to semicolons in URLs.\n" unless ($quiet); + $session->db->write("alter table HttpProxy add column useAmpersand int not null default 0"); +} + +#------------------------------------------------- +sub fixOrphans { + print "\tFixing orphans created by 7fixup.\n" unless ($quiet); + my $db = $session->db; + $db->write("delete from template where assetId='9tBSOV44a9JPS8CcerOvYw'"); + $db->write("delete from template where assetId='B1bNjWVtzSjsvGZh9lPz_A'"); +} + + #------------------------------------------------- sub fixSurvey{ my $session = shift; diff --git a/lib/WebGUI/Asset/Wobject/HttpProxy.pm b/lib/WebGUI/Asset/Wobject/HttpProxy.pm index b0f1c3f73..137e065b6 100644 --- a/lib/WebGUI/Asset/Wobject/HttpProxy.pm +++ b/lib/WebGUI/Asset/Wobject/HttpProxy.pm @@ -24,6 +24,20 @@ use WebGUI::Cache; our @ISA = qw(WebGUI::Asset::Wobject); +#------------------------------------------------------------------- +sub appendToUrl { + my $self = shift; + my $url = shift; + my $paramSet = shift; + my $seperator = ($self->get("useAmpersand")) ? "&" : ";"; + if ($url =~ /\?/) { + $url .= $seperator.$paramSet; + } else { + $url .= '?'.$paramSet; + } + return $url; +} + #------------------------------------------------------------------- sub definition { @@ -46,6 +60,10 @@ sub definition { fieldType=>"url", defaultValue=>'http://' }, + useAmpersand=>{ + fieldType=>"yesNo", + defaultValue=>0 + }, timeout=>{ fieldType=>"selectBox", defaultValue=>30 @@ -179,6 +197,12 @@ sub getEditForm { -hoverHelp=>$i18n->get('14 description'), -value=>$self->getValue("stopAt") ); + $tabform->getTab("properties")->yesNo( + name=>"useAmpersand", + value=>$self->getValue("useAmpersand"), + label=>$i18n->get("use ampersand"), + hoverHelp=>$i18n->get("use ampersand help") + ); return $tabform; } @@ -276,7 +300,7 @@ sub view { foreach my $input_name ($self->session->form->param) { next if ($input_name !~ /^HttpProxy_/); # Skip non proxied form var's $input_name =~ s/^HttpProxy_//; - $proxiedUrl=$self->session->url->append($proxiedUrl,"$input_name=".$self->session->form->process('HttpProxy_'.$input_name)); + $proxiedUrl=$self->appendToUrl($proxiedUrl,"$input_name=".$self->session->form->process('HttpProxy_'.$input_name)); } } $request = HTTP::Request->new(GET => $proxiedUrl, $header) || return "wrong url"; # Create GET request @@ -385,6 +409,7 @@ sub view { sub www_view { my $self = shift; return $self->session->privilege->noAccess() unless $self->canView; + $self->prepareView; my $output = $self->view; # this is s a stop gap. we need to do something here that deals with the real www_view and caching, etc. if ($self->session->http->getMimeType() ne "text/html") { diff --git a/lib/WebGUI/Help/Asset_HttpProxy.pm b/lib/WebGUI/Help/Asset_HttpProxy.pm index 301ceda92..f5a82da3a 100644 --- a/lib/WebGUI/Help/Asset_HttpProxy.pm +++ b/lib/WebGUI/Help/Asset_HttpProxy.pm @@ -35,6 +35,11 @@ our $HELP = { description => 'cache timeout description', namespace => 'Asset_HttpProxy', }, + { + title => 'use ampersand', + description => 'use ampersand help', + namespace => 'Asset_HttpProxy', + }, { title => '6', description => '6 description', diff --git a/lib/WebGUI/i18n/English/Asset_HttpProxy.pm b/lib/WebGUI/i18n/English/Asset_HttpProxy.pm index c1cea548a..266397714 100644 --- a/lib/WebGUI/i18n/English/Asset_HttpProxy.pm +++ b/lib/WebGUI/i18n/English/Asset_HttpProxy.pm @@ -1,6 +1,18 @@ package WebGUI::i18n::English::Asset_HttpProxy; our $I18N = { + 'use ampersand help' => { + message => q|By default we use semicolons to seperate parameters in a URL. However, some older applications require the use of ampersands.|, + context => q|asset property hover help|, + lastUpdated => 0 + }, + + 'use ampersand' => { + message => q|Use ampersand as seperator?|, + context => q|asset property|, + lastUpdated => 0 + }, + 'cache timeout description' => { message => q|How long should the proxy cache a page, so that if it's requested again, it won't have to refetch it?|, lastUpdated => 1047837230