--- sites/all/modules/pathauto/pathauto.inc	2010-06-10 16:48:10.000000000 +0100
+++ sites/all/modules/pathauto/pathauto.inc.new	2010-09-14 01:11:12.000000000 +0100
@@ -74,6 +74,42 @@ function _pathauto_existing_alias_data($
 }
 
 /**
+ * Get the configuration options for pathauto_cleanstring().
+ *
+ * @return
+ *   The cleanstring configuration.
+ */
+function pathauto_get_configuration_cleanstring($object) {
+  static $configuration = NULL;
+  
+  if (is_null($configuration)) {
+    // Default words to ignore
+    static $ignore_words = array(
+      'a', 'an', 'as', 'at', 'before', 'but', 'by', 'for', 'from', 'is', 'in',
+      'into', 'like', 'of', 'off', 'on', 'onto', 'per', 'since', 'than', 'the',
+      'this', 'that', 'to', 'up', 'via', 'with',
+    );
+    
+    $configuration = array(
+      'separator' => variable_get('pathauto_separator', '-'),
+      'transliterate' => variable_get('pathauto_transliterate', FALSE),
+      'reduce_ascii' => variable_get('pathauto_reduce_ascii', FALSE),
+      'max_component_length' => variable_get('pathauto_max_component_length', 100),
+      'ignore_words' => variable_get('pathauto_ignore_words', $ignore_words)
+    );
+    
+    $punctuation = pathauto_punctuation_chars();
+    foreach ($punctuation as $name => $details) {
+      $configuration['punctuation_'. $name] = variable_get('pathauto_punctuation_'. $name, 0);
+    }
+    
+    drupal_alter('pathauto_cleanstring_config', $configuration $object);
+  }
+    
+  return $configuration;
+}
+
+/**
  * Clean up a string value provided by a module.
  *
  * Resulting string contains only alphanumerics and separators.
@@ -85,20 +121,15 @@ function _pathauto_existing_alias_data($
  * @return
  *   The cleaned string.
  */
-function pathauto_cleanstring($string, $is_path = FALSE) {
-  // Default words to ignore
-  $ignore_words = array(
-    'a', 'an', 'as', 'at', 'before', 'but', 'by', 'for', 'from', 'is', 'in',
-    'into', 'like', 'of', 'off', 'on', 'onto', 'per', 'since', 'than', 'the',
-    'this', 'that', 'to', 'up', 'via', 'with',
-  );
+function pathauto_cleanstring($string, $is_path = FALSE, $configuration = array(), $object = NULL) {
+  $configuration = pathauto_get_configuration_cleanstring($object) + (array) $configuration;
 
   // Replace or drop punctuation based on user settings
-  $separator = variable_get('pathauto_separator', '-');
+  $separator = $configuration['separator'];
   $output = $string;
   $punctuation = pathauto_punctuation_chars();
   foreach ($punctuation as $name => $details) {
-    $action = variable_get('pathauto_punctuation_'. $name, 0);
+    $action = $configuration['punctuation_'. $name];
     // 2 is the action for "do nothing" with the punctuation
     if ($action != 2) {
       // Slightly tricky inline if which either replaces with the separator or nothing
@@ -112,7 +143,7 @@ function pathauto_cleanstring($string, $
   }
 
   // Optionally remove accents and transliterate
-  if (variable_get('pathauto_transliterate', FALSE)) {
+  if ($configuration['transliterate']) {
     static $i18n_loaded = false;
     static $translations = array();
 
@@ -128,7 +159,7 @@ function pathauto_cleanstring($string, $
   }
 
   // Reduce to the subset of ASCII96 letters and numbers
-  if (variable_get('pathauto_reduce_ascii', FALSE)) {
+  if ($configuration['reduce_ascii']) {
     $pattern = '/[^a-zA-Z0-9\/]+/ ';
     $output = preg_replace($pattern, $separator, $output);
   }
@@ -136,7 +167,7 @@ function pathauto_cleanstring($string, $
   // Path or URL related tokens should not have ignore words removed.
   if (!$is_path) {
     // Get rid of words that are on the ignore list
-    $ignore_re = '\b'. preg_replace('/,/', '\b|\b', variable_get('pathauto_ignore_words', $ignore_words)) .'\b';
+    $ignore_re = '\b'. preg_replace('/,/', '\b|\b', $configuration['ignore_words']) .'\b';
 
     if (function_exists('mb_eregi_replace')) {
       $output = mb_eregi_replace($ignore_re, '', $output);
@@ -153,7 +184,7 @@ function pathauto_cleanstring($string, $
   $output = _pathauto_clean_separators($output, $separator);
 
   // Enforce the maximum component length
-  $maxlength = min(variable_get('pathauto_max_component_length', 100), 128);
+  $maxlength = min($configuration['max_component_length'], 128);
   $output = drupal_substr($output, 0, $maxlength);
 
   return $output;
@@ -453,7 +484,7 @@ function pathauto_get_placeholders($type
   if (function_exists('token_get_values')) {
     $full = token_get_values($type, $object, TRUE);
     $tokens = token_prepare_tokens($full->tokens);
-    $values = pathauto_clean_token_values($full);
+    $values = pathauto_clean_token_values($full, $object);
     return array('tokens' => $tokens, 'values' => $values);
   }
   // TODO at some point try removing this and see if install profiles have problems again.
@@ -469,14 +500,14 @@ function pathauto_get_placeholders($type
  * @return
  *   An array of the cleaned tokens.
  */
-function pathauto_clean_token_values($full) {
+function pathauto_clean_token_values($full, $object = NULL) {
   foreach ($full->values as $key => $value) {
     // If it's a "path" or "url friendly" token don't remove the "/" character
     if (drupal_substr($full->tokens[$key], -4, 4) === 'path' || drupal_substr($full->tokens[$key], -8, 8) === 'path-raw' || drupal_substr($full->tokens[$key], -5, 5) === 'alias') {
-      $full->values[$key] = pathauto_cleanstring($value, TRUE);
+      $full->values[$key] = pathauto_cleanstring($value, TRUE, array(), $object);
     }
     else {
-      $full->values[$key] = pathauto_cleanstring($value);
+      $full->values[$key] = pathauto_cleanstring($value, FALSE, array(), $object);
     }
   }
   return $full->values;
