diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index a1dddf6ab..f9cb8e71c 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -28,6 +28,8 @@ - fixed: Ribbons and Tokens on badge page error - fixed: Variable 'description' not filled in RSS templates - fixed: logging reports incorrect location + - fixed: Cart now redirects to ssl if the site is ssl enabled. + - added: Session/Url now has a forceToSecure method which takes a page or site url and redirects to that page or url if the site is ssl enabled. 7.5.17 - fixed: Payment Methods Hover Help Incomplete diff --git a/lib/WebGUI/Session/Url.pm b/lib/WebGUI/Session/Url.pm index 5ac3aefec..f5cd15b3c 100644 --- a/lib/WebGUI/Session/Url.pm +++ b/lib/WebGUI/Session/Url.pm @@ -241,6 +241,43 @@ sub getRefererUrl { } } +#------------------------------------------------------------------- + +=head2 forceSecureConnection( url ) + +Attempts to create an SSL connection with the current or passed in url. + +=head3 url + +The optional url that the page should forward to as an SSL connection. + +=cut + +sub forceSecureConnection{ + my $self = shift; + my $url = shift; + my ($conf, $env, $http) = $self->session->quick(qw(config env http)); + + if ($conf->get("sslEnabled") && $env->get("HTTPS") ne "on" && !$env->get("SSLPROXY")){ + + $url = $self->session->url->page if(! $url); + $url = $self->session->env->get('QUERY_STRING') if(! $url); + + if($url !~ /^$self->getSiteURL()/i){ + $url = $self->getSiteURL() . $url; + } + if($env->get('QUERY_STRING')){ + $url .= "?". $env->get('QUERY_STRING'); + } + if($url =~ /^http/i) { + $url =~ s/^https?/https/i; + $http->setRedirect($url); + return 1; + } + } + return 0; +} + #------------------------------------------------------------------- diff --git a/lib/WebGUI/Shop/Cart.pm b/lib/WebGUI/Shop/Cart.pm index 114712dd0..b933b5583 100644 --- a/lib/WebGUI/Shop/Cart.pm +++ b/lib/WebGUI/Shop/Cart.pm @@ -678,7 +678,10 @@ sub www_view { my $url = $session->url; my $i18n = WebGUI::International->new($session, "Shop"); my @items = (); - + + if($url->forceSecureConnection()){ + return "redirect"; + } # set up html header $session->style->setRawHeadTags(q|