Problem/Motivation

On our "user/register" page, secure pages redirects properly to https, but the form action submits improperly to http. This wasn't happening before we upgraded from the 6.x-1.9 branch to the 6.x-2.x-dev branch.

Proposed resolution

The following won't extract the path component correctly if the form action url is absolute:

$url = substr($form['#action'], strlen(base_path()));

If we run the @parse_url() function first, then strip the base path from $url['path'], we can account for whether the form action url is absolute or relative:

$url = @parse_url($form['#action']);
$path = drupal_get_normal_path(substr($url['path'], strlen(base_path())));

Patch will be attached.

Comments

djbobbydrake’s picture

Status: Active » Needs review
StatusFileSize
new904 bytes

Patch attached.

bisonbleu’s picture

Hey djbobbydrake,

How would you reconcile/combine your patch and the code from this issue https://drupal.org/node/1145292#comment-6042150 ?

My site is multilingual and uses language prefixes (i18n). Without the code from #1145292, URLs are broken.

p.s. when patching, I get this error:

Hunk #2 FAILED at 294.

Minor detail. :-)

bisonbleu’s picture

Update.

Using just your patch doesn't fix the language prefix issue raised in #1145292. When I tried to log in from mysite.com/user I got an access denied error message. Looking at the resulting URL tells it all: https://mysite.com/en/en/user.

Note the double 'en' language prefix.

My question in #2 then still stands. It would be awesome if you could revisit your patch in light of what was done in #1145292 for multilingual websites.

p.s. My hope is that this patch combined with your 2 recent other patches (#1647760 and #1638004 ) will fix a couple of 'frustrating' issues I've been having with Secure Pages. Thanks a lot.

djbobbydrake’s picture

@bisonbleu, I'll revisit this patch when I get a chance. Thanks for the reply.

djbobbydrake’s picture

StatusFileSize
new1.36 KB

Got it. Here's the patch. It incorporates the fix from #1145292. I tested myself and looks to solve both issues.

djbobbydrake’s picture

I should also mention that I modified the regex slightly (in https://drupal.org/node/1145292#comment-6042150) to be more specific.

bisonbleu’s picture

Hello DJ,

I've applied your latest patch on 2 live multilingual Ubercart websites. Works great. Can't fault it. This is awesome. Thanks a lot! I owe you one. :-)

Now if I could only get closure for # 1363158, I would be a vey happy camper...

astonvictor’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)

I'm closing it because the issue was created a long time ago without any further steps.

if you still need it then raise a new one.
thanks