Index: nodewords.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodewords/nodewords.module,v
retrieving revision 1.57.2.363
diff -u -p -r1.57.2.363 nodewords.module
--- nodewords.module	31 Oct 2010 20:44:08 -0000	1.57.2.363
+++ nodewords.module	31 Oct 2010 20:57:46 -0000
@@ -563,79 +563,81 @@ function nodewords_replace_tokens($conte
       // Since a custom page can be virtually anything, we need to load global
       // tokens and check arg(0) to see if there are additional tokens that we
       // need to bring into scope.
-      $token_objects['global'] = NULL;
-      $token_objects['global meta tags'] = NULL;
-      $arg = arg();
+      $arg = arg() + array_fill(0, MENU_MAX_PARTS, NULL);
       if (!empty($arg[0])) {
         switch ($arg[0]) {
           // Core node.module.
           case 'node':
             $node_options = array();
             node_nodewords_type_id($node_options, $arg);
-            $token_objects['node'] = _nodewords_node_load($node_options);
-            $token_objects['node meta tags'] = $token_objects['node'];
+            if (!empty($node_options)) {
+              $token_objects['node'] = _nodewords_node_load($node_options);
+              $token_objects['node meta tags'] = $token_objects['node'];
+            }
             break;
           // Core user.module.
           case 'user':
             $user_options = array();
             user_metatags_type($user_options, $arg);
-            $token_objects['user'] = user_load($user_options['id']);
+            if (!empty($user_options)) {
+              $token_objects['user'] = user_load($user_options['id']);
+            }
             break;
           // Core taxonomy.module.
           case 'taxonomy':
             $taxonomy_options = array();
             taxonomy_nodewords_type_id($taxonomy_options, $arg);
-            $token_objects['taxonomy'] = _nodewords_taxonomy_object_load($taxonomy_options);
+            if (!empty($taxonomy_options)) {
+              $token_objects['taxonomy'] = _nodewords_taxonomy_object_load($taxonomy_options);
+            }
             break;
           // Core forum.module.
           case 'forum':
             $forum_options = array();
             forum_nodewords_type_id($forum_options, $arg);
-            $token_objects['taxonomy'] = _nodewords_taxonomy_object_load($forum_options);
+            if (!empty($forum_options)) {
+              $token_objects['taxonomy'] = _nodewords_taxonomy_object_load($forum_options);
+            }
             break;
           // Contrib image.module.
           case 'image':
             $image_options = array();
             image_nodewords_type_id($image_options, $arg);
-            $token_objects['taxonomy'] = _nodewords_taxonomy_object_load($image_options);
+            if (!empty($image_options)) {
+              $token_objects['taxonomy'] = _nodewords_taxonomy_object_load($image_options);
+            }
             break;
           // Contrib ubercart.module.
           case 'catalog':
             $uc_catalog_options = array();
             forum_nodewords_type_id($uc_catalog_options, $arg);
-            $token_objects['taxonomy'] = _nodewords_taxonomy_object_load($uc_catalog_options);
+            if (!empty($uc_catalog_options)) {
+              $token_objects['taxonomy'] = _nodewords_taxonomy_object_load($uc_catalog_options);
+            }
             break;
           // Contrib taxonomy_menu.module.
           case 'taxonomy_menu':
             $taxonomy_menu_options = array();
             taxonomy_menu_nodewords_type_id($taxonomy_menu_options, $arg);
-            $token_objects['taxonomy'] = _nodewords_taxonomy_object_load($taxonomy_menu_options);
+            if (!empty($taxonomy_menu_options)) {
+              $token_objects['taxonomy'] = _nodewords_taxonomy_object_load($taxonomy_menu_options);
+            }
             break;
         }
       }
       break;
-    case NODEWORDS_TYPE_ERRORPAGE:
-      $token_objects['global'] = NULL;
-      $token_objects['global meta tags'] = NULL;
-      break;
 
     case NODEWORDS_TYPE_NODE:
-      $token_objects['global'] = NULL;
-      $token_objects['global meta tags'] = NULL;
       $token_objects['node'] = _nodewords_node_load($options);
       $token_objects['node meta tags'] = $token_objects['node'];
       break;
 
     case NODEWORDS_TYPE_TERM:
     case NODEWORDS_TYPE_VOCABULARY:
-      $token_objects['global'] = NULL;
-      $token_objects['global meta tags'] = NULL;
       $token_objects['taxonomy'] = _nodewords_taxonomy_object_load($options);
       break;
 
     case NODEWORDS_TYPE_USER:
-      $token_objects['global'] = NULL;
-      $token_objects['global meta tags'] = NULL;
       $token_objects['user'] = user_load($options['id']);
       break;
 
@@ -643,6 +645,9 @@ function nodewords_replace_tokens($conte
       return $content;
   }
 
+  $token_objects['global'] = NULL;
+  $token_objects['global meta tags'] = NULL;
+
   // Remove the not replaced tokens.
   $content = token_replace_multiple($content, $token_objects);
   $replacements = array();
Index: includes/image.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodewords/includes/image.inc,v
retrieving revision 1.1.4.7
diff -u -p -r1.1.4.7 image.inc
--- includes/image.inc	21 Mar 2010 13:11:23 -0000	1.1.4.7
+++ includes/image.inc	31 Oct 2010 20:57:46 -0000
@@ -16,7 +16,7 @@ function image_nodewords_type_id(&$resul
       $result['type'] = NODEWORDS_TYPE_VOCABULARY;
       $result['id'] = variable_get('image_gallery_nav_vocabulary', 0);
     }
-    elseif (isset($arg[2]) && is_numeric($arg[2])) {
+    elseif (is_numeric($arg[2])) {
       $result['type'] = NODEWORDS_TYPE_TERM;
       $result['id'] = $arg[1];
     }
Index: includes/node.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodewords/includes/node.inc,v
retrieving revision 1.1.4.11
diff -u -p -r1.1.4.11 node.inc
--- includes/node.inc	19 May 2010 20:20:28 -0000	1.1.4.11
+++ includes/node.inc	31 Oct 2010 20:57:46 -0000
@@ -10,24 +10,10 @@
  * Implements hook_nodewords_type_id().
  */
 function node_nodewords_type_id(&$result, $arg) {
-  if ($arg[0] == 'node') {
-    // Node paths: node/$nid.
-    $bool = (
-      isset($arg[1]) && is_numeric($arg[1]) && ($node = menu_get_object())
-    );
-    if ($bool) {
-      $bool = (
-        (
-          $node->type == 'poll' &&
-          isset($arg[2]) &&
-          in_array($arg[2], array('edit', 'results'))
-        ) ||
-        !isset($arg[2])
-      );
-      if ($bool) {
-        $result['type'] = NODEWORDS_TYPE_NODE;
-        $result['id'] = $node->nid;
-      }
+  if ($arg[0] == 'node' && is_numeric($arg[1]) && $node = node_load($arg[1])) {
+    if (!isset($arg[2]) || ($node->type == 'poll' && in_array($arg[2], array('edit', 'results')))) {
+      $result['type'] = NODEWORDS_TYPE_NODE;
+      $result['id'] = $node->nid;
     }
   }
 }
Index: includes/taxonomy.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodewords/includes/taxonomy.inc,v
retrieving revision 1.1.4.9
diff -u -p -r1.1.4.9 taxonomy.inc
--- includes/taxonomy.inc	21 Mar 2010 13:11:23 -0000	1.1.4.9
+++ includes/taxonomy.inc	31 Oct 2010 20:57:46 -0000
@@ -10,19 +10,17 @@
  * Implements hook_nodewords_type_id().
  */
 function taxonomy_nodewords_type_id(&$result, $arg) {
-  if ($arg[0] == 'taxonomy') {
+  if ($arg[0] == 'taxonomy' && $arg[1] == 'term' && !empty($arg[2])) {
     // Taxonomy paths: taxonomy/term/$tid , taxonomy/term/$tid1+$tid2.
-    if (isset($arg[1]) && isset($arg[2]) && $arg[1] == 'term') {
-      $ids = preg_split('![+, ]!', $arg[2]);
+    $ids = preg_split('![+, ]!', $arg[2]);
 
-      if (count($ids)) {
-        // Take the first ID that is numeric.
-        foreach ($ids as $id) {
-          if (is_numeric($id)) {
-            $result['type'] = NODEWORDS_TYPE_TERM;
-            $result['id'] = $id;
-            return;
-          }
+    if (count($ids)) {
+      // Take the first ID that is numeric.
+      foreach ($ids as $id) {
+        if (is_numeric($id)) {
+          $result['type'] = NODEWORDS_TYPE_TERM;
+          $result['id'] = $id;
+          return;
         }
       }
     }
Index: includes/uc_catalog.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodewords/includes/Attic/uc_catalog.inc,v
retrieving revision 1.1.2.6
diff -u -p -r1.1.2.6 uc_catalog.inc
--- includes/uc_catalog.inc	19 May 2010 20:20:28 -0000	1.1.2.6
+++ includes/uc_catalog.inc	31 Oct 2010 20:57:46 -0000
@@ -10,11 +10,7 @@
  * Implements hook_nodewords_type_id().
  */
 function uc_catalog_nodewords_type_id(&$result, $arg) {
-  $bool = (
-    $arg[0] == 'catalog' &&
-    isset($arg[1]) && is_numeric($arg[1])
-  );
-  if ($bool) {
+  if ($arg[0] == 'catalog' && is_numeric($arg[1])) {
     $result['type'] = NODEWORDS_TYPE_TERM;
     $result['id'] = $arg[1];
   }
Index: includes/user.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodewords/includes/user.inc,v
retrieving revision 1.1.4.10
diff -u -p -r1.1.4.10 user.inc
--- includes/user.inc	19 May 2010 20:20:28 -0000	1.1.4.10
+++ includes/user.inc	31 Oct 2010 20:57:46 -0000
@@ -10,12 +10,8 @@
  * Implements hook_nodewords_type_id().
  */
 function user_metatags_type(&$result, $arg) {
-  $bool = (
-    $arg[0] == 'user' &&
-    isset($arg[1]) && is_numeric($arg[1])
-  );
-  if ($bool) {
+  if ($arg[0] == 'user' && is_numeric($arg[1]) && $account = user_load($arg[1])) {
     $result['type'] = NODEWORDS_TYPE_USER;
-    $result['id'] = $arg[1];
+    $result['id'] = $account->uid;
   }
 }
