From 26f0dfc077730444ef08ddf2d7e9785c6f1797d4 Mon Sep 17 00:00:00 2001 From: Len Kranendonk Date: Thu, 19 Jun 2003 11:46:17 +0000 Subject: [PATCH] RFE 716714: Added "Rewrite urls" option. --- docs/upgrades/upgrade_5.3.3-5.4.0.sql | 4 +++- lib/WebGUI/Wobject/HttpProxy.pm | 10 +++++++++- lib/WebGUI/Wobject/HttpProxy/Parse.pm | 3 ++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/docs/upgrades/upgrade_5.3.3-5.4.0.sql b/docs/upgrades/upgrade_5.3.3-5.4.0.sql index 362638cdb..bea6d3789 100644 --- a/docs/upgrades/upgrade_5.3.3-5.4.0.sql +++ b/docs/upgrades/upgrade_5.3.3-5.4.0.sql @@ -1,4 +1,6 @@ insert into webguiVersion values ('5.4.0','upgrade',unix_timestamp()); insert into international (internationalId,languageId,namespace,message,lastUpdated) values (979,1,'WebGUI','Are you certain you wish to delete all items in this folder? They cannot be recovered once deleted. Items in sub-folders will not be removed.',1055908341); insert into international (internationalId,languageId,namespace,message,lastUpdated) values (980,1,'WebGUI','Empty this folder.',1055908341); - +alter table HttpProxy add column rewriteUrls int; +update HttpProxy set rewriteUrls = 1; +insert into international (internationalId,languageId,namespace,message,lastUpdated) values (12,1,'HttpProxy','Rewrite urls ?',1055908341); diff --git a/lib/WebGUI/Wobject/HttpProxy.pm b/lib/WebGUI/Wobject/HttpProxy.pm index 93e1685da..0dbe8e835 100644 --- a/lib/WebGUI/Wobject/HttpProxy.pm +++ b/lib/WebGUI/Wobject/HttpProxy.pm @@ -54,6 +54,9 @@ sub new { followExternal=>{ defaultValue=>1 }, + rewriteUrls=>{ + defaultValue=>1 + }, followRedirect=>{ defaultValue=>0 } @@ -90,6 +93,11 @@ sub www_edit { -label=>WebGUI::International::get(8,$_[0]->get("namespace")), -value=>$_[0]->getValue("followRedirect") ); + $properties->yesNo( + -name=>"rewriteUrls", + -label=>WebGUI::International::get(12,$_[0]->get("namespace")), + -value=>$_[0]->getValue("rewriteUrls") + ); $layout->yesNo( -name=>"removeStyle", -label=>WebGUI::International::get(6,$_[0]->get("namespace")), @@ -226,7 +234,7 @@ sub www_view { if($response->content_type eq "text/html" || ($response->content_type eq "" && $content=~/new($proxiedUrl, $content, $_[0]->get("wobjectId")); + my $p = WebGUI::Wobject::HttpProxy::Parse->new($proxiedUrl, $content, $_[0]->get("wobjectId"),$_[0]->get("rewriteUrls")); $content = $p->filter; # Rewrite content. (let forms/links return to us). $p->DESTROY; diff --git a/lib/WebGUI/Wobject/HttpProxy/Parse.pm b/lib/WebGUI/Wobject/HttpProxy/Parse.pm index c73cca2a4..272e2a613 100644 --- a/lib/WebGUI/Wobject/HttpProxy/Parse.pm +++ b/lib/WebGUI/Wobject/HttpProxy/Parse.pm @@ -51,6 +51,7 @@ sub new { $self->{Url} = shift; $self->{Content} = shift; $self->{wid} = shift; + $self->{rewriteUrls} = shift; $self->{Filtered} =""; $self->{FormAction} = ""; $self->{FormActionIsDefined} = 0; @@ -120,7 +121,7 @@ sub start { $val = URI::URL::url($val)->abs($self->{Url},1); # make absolute } if ($val->scheme eq "http") { - if (lc($tag) ne "img" && lc($tag) ne "script" && lc($tag) ne "iframe") { # no rewrite for some + if (lc($tag) ne "img" && lc($tag) ne "script" && lc($tag) ne "iframe" && $self->{rewriteUrls}) { # no rewrite for some if (lc($tag) eq "form" && lc($_) eq "action") { # Found FORM ACTION $self->{FormActionIsDefined}=1; $self->{FormAction} = $val; # set FormAction to include hidden field later