kolab.org/www

Torsten Grote grote at kolabsys.com
Tue Jun 19 10:24:40 CEST 2012


 kolab.org/www/drupal-6.26/sites/all/modules/globalredirect/globalredirect.admin.inc |    7 +
 kolab.org/www/drupal-6.26/sites/all/modules/globalredirect/globalredirect.info      |    6 -
 kolab.org/www/drupal-6.26/sites/all/modules/globalredirect/globalredirect.module    |   12 ++-
 kolab.org/www/drupal-6.26/sites/all/modules/globalredirect/globalredirect.test      |   40 ++++++++--
 4 files changed, 55 insertions(+), 10 deletions(-)

New commits:
commit 38fa9bb6d0ae25546a933615f5e32aa6e4d68b40
Author: Torsten Grote <grote at kolabsys.com>
Date:   Tue Jun 19 10:24:19 2012 +0200

    updated Global Redirect module

diff --git a/kolab.org/www/drupal-6.26/sites/all/modules/globalredirect/globalredirect.admin.inc b/kolab.org/www/drupal-6.26/sites/all/modules/globalredirect/globalredirect.admin.inc
index 371317e..725da13 100644
--- a/kolab.org/www/drupal-6.26/sites/all/modules/globalredirect/globalredirect.admin.inc
+++ b/kolab.org/www/drupal-6.26/sites/all/modules/globalredirect/globalredirect.admin.inc
@@ -96,6 +96,13 @@ function globalredirect_settings() {
     '#default_value' => $settings['frontpage_redirect'],
   );
 
+  $form['settings']['ignore_admin_path'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Ignore Admin Path'),
+    '#description' => t('If enabled, any request to the admin section of the site will be ignored by Global Redirect.<br />
+                         This is useful if you are experiencing problems with Global Redirect and want to protect the admin section of your website. NOTE: This may not be desirable if you are using path aliases for certain admin URLs.'),
+    '#default_value' => $settings['ignore_admin_path'],
+  );
 
   $form['buttons']['submit'] = array(
     '#type' => 'submit',
diff --git a/kolab.org/www/drupal-6.26/sites/all/modules/globalredirect/globalredirect.info b/kolab.org/www/drupal-6.26/sites/all/modules/globalredirect/globalredirect.info
index 500db8f..cdb384b 100644
--- a/kolab.org/www/drupal-6.26/sites/all/modules/globalredirect/globalredirect.info
+++ b/kolab.org/www/drupal-6.26/sites/all/modules/globalredirect/globalredirect.info
@@ -2,9 +2,9 @@ name = Global Redirect
 description = "Searches for an alias of the current URL and 301 redirects if found. Stops duplicate content arising when path module is enabled."
 core = 6.x
 
-; Information added by drupal.org packaging script on 2011-12-21
-version = "6.x-1.4"
+; Information added by drupal.org packaging script on 2012-06-15
+version = "6.x-1.5"
 core = "6.x"
 project = "globalredirect"
-datestamp = "1324428084"
+datestamp = "1339752680"
 
diff --git a/kolab.org/www/drupal-6.26/sites/all/modules/globalredirect/globalredirect.module b/kolab.org/www/drupal-6.26/sites/all/modules/globalredirect/globalredirect.module
index 22a9f72..715e90f 100644
--- a/kolab.org/www/drupal-6.26/sites/all/modules/globalredirect/globalredirect.module
+++ b/kolab.org/www/drupal-6.26/sites/all/modules/globalredirect/globalredirect.module
@@ -248,7 +248,7 @@ function globalredirect_goto($path = '', $query = NULL, $fragment = NULL, $http_
  */
 function globalredirect_url_is_external($path) {
   $colonpos = strpos($path, ':');
-  return $colonpos !== FALSE && !preg_match('![/?#]!', substr($path, 0, $colonpos));
+  return $colonpos !== FALSE && !preg_match('![/?#]!', drupal_substr($path, 0, $colonpos));
 }
 
 /**
@@ -330,6 +330,15 @@ function _globalredirect_is_active($settings) {
   }
 
   /**
+   * If we're going to ignore the admin path, return false.
+   * This is added to allow people to continue to get to the 'admin*' and 'batch*' paths,
+   * even if the module is misbehaving.
+   */
+  if ($settings['ignore_admin_path'] && (arg(0) == 'admin' || arg(0) == 'batch')) {
+    return FALSE;
+  }
+
+  /**
    * We seem to have passed all the tests - let say we're active
    */
   return TRUE;
@@ -350,6 +359,7 @@ function _globalredirect_get_settings($default_only = FALSE) {
     'content_location_header' => 0,
     'term_path_handler' => 1,
     'frontpage_redirect' => 1,
+    'ignore_admin_path' => 1,
   );
 
   if ($default_only) {
diff --git a/kolab.org/www/drupal-6.26/sites/all/modules/globalredirect/globalredirect.test b/kolab.org/www/drupal-6.26/sites/all/modules/globalredirect/globalredirect.test
index dc39d46..4c68346 100644
--- a/kolab.org/www/drupal-6.26/sites/all/modules/globalredirect/globalredirect.test
+++ b/kolab.org/www/drupal-6.26/sites/all/modules/globalredirect/globalredirect.test
@@ -1,7 +1,8 @@
 <?php
 
-define('ERROR_MESSAGE',     'ERROR<br />Expected Path: !expected_path<br />Expected Status Code: !expected_status<br />Location: !location<br />Status: !status');
+define('ERROR_MESSAGE',   'ERROR<br />Expected Path: !expected_path<br />Expected Status Code: !expected_status<br />Location: !location<br />Status: !status');
 define('SUCCESS_MESSAGE', 'SUCCESS<br />Expected Path: !expected_path<br />Expected Status Code: !expected_status<br />Location: !location<br />Status: !status');
+define('INFO_MESSAGE',    'Running Test: !id<br />Requesting URL: !url');
 
 /**
  * @file
@@ -23,6 +24,7 @@ class GlobalRedirectTestCase extends DrupalWebTestCase {
       'access content',
       'create page content',
       'create url aliases',
+      'access administration pages', // For the 'ignore admin path' test
     ));
     $this->drupalLogin($user);
 
@@ -39,6 +41,9 @@ class GlobalRedirectTestCase extends DrupalWebTestCase {
     // Create an alias for the create story path - this is used in the "redirect with permissions testing" test.
     path_set_alias('node/add/story', 'add-node-story');
 
+    // Create an alias for the admin URL - this is used in the "ignore admin path" test.
+    path_set_alias('admin', 'administration');
+
 
     // The forum vocab should already be created - should be term 1?
     $forum_term = array(
@@ -201,18 +206,39 @@ class GlobalRedirectTestCase extends DrupalWebTestCase {
         'expected-path' => $settings['trailing_zero'] > 0 ? 'taxonomy/term/10' : 'taxonomy/term/10/0',
       ),
 
+      // Regression test for http://drupal.org/node/867654 - term 10 does not exist
+      array(
+        'request' => 'admin',
+        'return-code' => $settings['ignore_admin_path'] > 0 ? 200 : 301, // Ignoring the admin path means no src=>alias redirecting.
+        'expected-path' => $settings['ignore_admin_path'] > 0 ? 'admin' : 'administration',
+      ),
     );
 
 
     // Foreach of the above, lets check they redirect correctly
-    foreach ($test_paths as $path) {
-      $path['options'] = isset($path['options']) ? $path['options'] + array('absolute' => TRUE) : array('absolute' => TRUE);
+    foreach ($test_paths as $id => $path) {
+      // Overlay some defaults onto the path. This ensures 'options' is set as an array.
+      $path += array(
+        'options' => array(),
+      );
 
-      $request_path = url($path['request'], $path['options'] + array('alias' => TRUE));
+      // If the path doesn't have an absolute or alias setting, set them to TRUE.
+      $path['options'] += array(
+        'absolute' => TRUE,
+        'alias' => TRUE,
+      );
+
+      // Build a URL from the path
+      $request_path = url($path['request'], $path['options']);
 
 
-      // Display a message tellingthe user what we're testing
-      $this->pass(t('Requesting: !path', array('!path' => $request_path)));
+      // Display a message telling the user what we're testing
+      $info = array(
+        '!id' => $id,
+        '!url' => $request_path,
+      );
+      $this->pass(t(INFO_MESSAGE, $info), 'GlobalRedirect');
+
 
       // Do a HEAD request (don't care about the body). The alias=>TRUE is to tell Drupal not to lookup the alias - this is a raw request.
       $this->drupalHead($request_path, array('alias' => TRUE));
@@ -297,6 +323,7 @@ class GlobalRedirectTestCaseDefault extends GlobalRedirectTestCase {
       'term_path_handler' => 0,
       'frontpage_redirect' => 1,
       'trailing_zero' => 0,
+      'ignore_admin_path' => 1,
     ));
     $this->_globalredirect_batch_test();
   }
@@ -320,6 +347,7 @@ class GlobalRedirectTestCaseConfigAlpha extends GlobalRedirectTestCase {
       'term_path_handler' => 1,
       'frontpage_redirect' => 0,
       'trailing_zero' => 1,
+      'ignore_admin_path' => 0,
     ));
 
     $this->_globalredirect_batch_test();





More information about the commits mailing list