I just found that this feature might be useful. In order to have an even more flexible configuration, I'd like the ability to force some URLs as HTTP regardless the rest of the settings.

Say for example I want to have one page of the admin section as HTTP but the rest as HTTPs, but the rest of the site in normal HTTP.

To do that now, I would have to specify each of the admin section I want with SSL and specifically not include the HTTP one, but this is a pain to configure and maintain.

So I created the HTTP force settings where any url there is forced to HTTP regardless of the settings above. It doesn't mess or harm what's already in the module and I think it adds value, a HTTPS force might be useful as well to go along this idea, but not sure.

Why I need this? Well, looking at http://drupal.org/node/255387 and http://drupal.org/node/18565 there seems to be a bug around Internet Explorer, SSL and drupal cache headers when downloading CSV files (Views Bonus or even Ubercart CSV export). While some ideas and suggestions are there to fix that, a small workaround is to not use SSL in those urls. Fitting that configuration into the current way of setting this module would led me to the pain I described above, then, I did this which is simpler and I think it might be useful.

I have patched version 1.6, if the patch does not apply to the 1.7 beta and you'd like me to port it to that version I won't mind doing it.

Hope this helps,
a.=

Comments

hanoii’s picture

Any chance this might got through? Any testing?

hanoii’s picture

Version: 5.x-1.6 » 5.x-1.7
StatusFileSize
new2.02 KB

I think the patch can be applied against 1.7 as well, but just in case, attached is a patch from the latest version (1.7). Any thoughts about this?

mrfelton’s picture

Status: Needs review » Needs work

+1 for this. I need be be able to force HTTPS on an entire section of the site, with the exception of a couple of pages, which must be served over HTTP. However, this patch needs to cater for url aliases too.

hanoii’s picture

The patches uses the exact same technique as the other fields of the module, and it will work fine with aliases as long as you enter them properly on the force http configuration field? Did you notice anything different?

mrfelton’s picture

I'm using the patch with The Drupal 6 version of the module, which actually takes consideration of the path alias when performing a match (I have no idea how the D5 version works).

I modified the securepages_match function like this to get it to work properly:

function securepages_match($path) {
  /**
   * Check to see if the page matches the current settings
   */
  $secure = variable_get('securepages_secure', 1);
  $pages = variable_get('securepages_pages', "node/add*\nnode/*/edit\nuser/*\nadmin*");
  $ignore = variable_get('securepages_ignore', "*/autocomplete/*\n*/ajax/*");
  $http = variable_get('securepages_http', "");

  if ($http) {
    $regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote($http, '/')) .')$/';
    $result = preg_match($regexp, $path);
    if (function_exists('drupal_get_path_alias')) {
      $path_alias = drupal_get_path_alias($path);
      $result |= preg_match($regexp, $path_alias);
    }
    if ($result) return 0;
  }
  if ($ignore) {
    $regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote($ignore, '/')) .')$/';
    $result = preg_match($regexp, $path);
    if (function_exists('drupal_get_path_alias')) {
      $path_alias = drupal_get_path_alias($path);
      $result |= preg_match($regexp, $path_alias);
    }
    if ($result) return securepages_is_secure() ? 1 : 0;
  }
  if ($pages) {
    $regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote($pages, '/')) .')$/';
    $result = preg_match($regexp, $path);
    if (function_exists('drupal_get_path_alias')) {
      $path_alias = drupal_get_path_alias($path);
      $result |= preg_match($regexp, $path_alias);
    }
    return !($secure xor $result) ? 1 : 0;
  }
  else {
    return;
  }
}

The difference is that I'm calling drupal_get_path_alias($path). In D6 CVS drupal_get_path_alias was already being called for the $pages section of that function - but not for any of the other ones, so I added it to those. With this alteration it seems to work well for me.

mrfelton’s picture

StatusFileSize
new3.41 KB

EDIT: IGNORE THIS PATCH - use the one on the following post

mrfelton’s picture

StatusFileSize
new2.93 KB

sorry.. new patch attached. That last one included part of some other unrelated changes to the module.

grendzy’s picture

Status: Needs work » Closed (won't fix)

The 5.x branch is no longer supported. If this issue is still present in a current version of Secure Pages, please update the issue summary, change the version field, and re-open the issue.