# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
--- Z:\drupal\sites\all\modules\securepages\securepages.module
+++ Z:\drupal\sites\all\modules\securepages\securepages2.module
@@ -78,6 +78,9 @@
     $url = drupal_parse_url($url);
     $path = drupal_get_normal_path($url['path']);
 
+    $path = _securepages_clean_path($path);
+    $url['path'] = $path;
+
     $page_match = securepages_match($path);
     if ($page_match && !securepages_is_secure()) {
       $form['#https'] = TRUE;
@@ -95,6 +98,27 @@
   }
 }
 
+function _securepages_clean_path($path) {
+  // Language friendly code
+    $languages = language_list();
+    if(count($languages) > 1) {
+      $path = explode("/", $path);
+      $path = array_unique($path);
+      foreach($languages as $language) {
+        foreach($path as $k => $v) {
+	  if($language->language == $v) {
+	    unset($path[$k]);
+	  }
+	}
+      }
+      if(is_array($path)) {
+	$path = implode("/", $path);
+	return $path;
+      }
+    }
+    return false;
+}
+
 /**
  * Implements hook_drupal_goto_alter().
  */
@@ -153,6 +177,9 @@
   $url['absolute'] = TRUE;
   $url['external'] = FALSE; // prevent an open redirect
 
+  $path = drupal_get_normal_path($url['path']);
+  $path = _securepages_clean_path($path);
+
   // Check for the overlay.  Attempting to switch protocols during an XHR
   // isn't allowed by the browser's same-origin policy, so we must close the overlay.
   if (isset($url['query']['render']) && $url['query']['render'] == 'overlay') {
@@ -161,6 +188,7 @@
   }
   else {
     // Setting the redirect headers manually allows them to be cached.
+    $url['path'] = $path;
     drupal_add_http_header('Location', url($url['path'], $url));
     drupal_add_http_header('Status', '302 Found');
     print "302 Found";
