Index: modules/block/block.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.module,v
retrieving revision 1.427
diff -u -p -r1.427 block.module
--- modules/block/block.module	31 Jul 2010 12:54:58 -0000	1.427
+++ modules/block/block.module	20 Aug 2010 04:29:43 -0000
@@ -245,7 +245,7 @@ function block_block_save($delta = 0, $e
  */
 function block_block_view($delta = 0, $edit = array()) {
   $block = db_query('SELECT body, format FROM {block_custom} WHERE bid = :bid', array(':bid' => $delta))->fetchObject();
-  $data['content'] = check_markup($block->body, $block->format, '', TRUE);
+  $data['content'] = check_markup($block->body, $block->format, array('cache' => TRUE, 'type' => 'block', 'object' => $block));
   return $data;
 }
 
Index: modules/book/book.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.test,v
retrieving revision 1.26
diff -u -p -r1.26 book.test
--- modules/book/book.test	5 Aug 2010 23:53:37 -0000	1.26
+++ modules/book/book.test	20 Aug 2010 04:29:43 -0000
@@ -158,7 +158,7 @@ class BookTestCase extends DrupalWebTest
     // Check printer friendly version.
     $this->drupalGet('book/export/html/' . $node->nid);
     $this->assertText($node->title, t('Printer friendly title found.'));
-    $this->assertRaw(check_markup($node->body[LANGUAGE_NONE][0]['value'], $node->body[LANGUAGE_NONE][0]['format']), t('Printer friendly body found.'));
+    $this->assertRaw(check_markup($node->body[LANGUAGE_NONE][0]['value'], $node->body[LANGUAGE_NONE][0]['format'], array('type' => 'node', 'object' => $node)), t('Printer friendly body found.'));
 
     $number++;
   }
@@ -227,7 +227,7 @@ class BookTestCase extends DrupalWebTest
     // Make sure each part of the book is there.
     foreach ($nodes as $node) {
       $this->assertText($node->title, t('Node title found in printer friendly version.'));
-      $this->assertRaw(check_markup($node->body[LANGUAGE_NONE][0]['value'], $node->body[LANGUAGE_NONE][0]['format']), t('Node body found in printer friendly version.'));
+      $this->assertRaw(check_markup($node->body[LANGUAGE_NONE][0]['value'], $node->body[LANGUAGE_NONE][0]['format'], array('type' => 'node', 'object' => $node)), t('Node body found in printer friendly version.'));
     }
     
     // Make sure we can't export an unsupported format.
Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.890
diff -u -p -r1.890 comment.module
--- modules/comment/comment.module	20 Aug 2010 01:21:14 -0000	1.890
+++ modules/comment/comment.module	20 Aug 2010 04:29:44 -0000
@@ -2120,7 +2120,7 @@ function comment_submit($comment) {
     // 1) Filter it into HTML
     // 2) Strip out all HTML tags
     // 3) Convert entities back to plain-text.
-    $comment->subject = truncate_utf8(trim(decode_entities(strip_tags(check_markup($comment->comment_body[LANGUAGE_NONE][0]['value'], $comment->comment_body[LANGUAGE_NONE][0]['format'])))), 29, TRUE);
+    $comment->subject = truncate_utf8(trim(decode_entities(strip_tags(check_markup($comment->comment_body[LANGUAGE_NONE][0]['value'], $comment->comment_body[LANGUAGE_NONE][0]['format'], array('type' => 'comment', 'object' => $comment))))), 29, TRUE);
     // Edge cases where the comment body is populated only by HTML tags will
     // require a default subject.
     if ($comment->subject == '') {
Index: modules/field/modules/text/text.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/modules/text/text.module,v
retrieving revision 1.61
diff -u -p -r1.61 text.module
--- modules/field/modules/text/text.module	17 Aug 2010 18:25:31 -0000	1.61
+++ modules/field/modules/text/text.module	20 Aug 2010 04:29:44 -0000
@@ -210,9 +210,9 @@ function text_field_load($entity_type, $
       // Only process items with a cacheable format, the rest will be handled
       // by formatters if needed.
       if (empty($instances[$id]['settings']['text_processing']) || filter_format_allowcache($item['format'])) {
-        $items[$id][$delta]['safe_value'] = isset($item['value']) ? _text_sanitize($instances[$id], $langcode, $item, 'value') : '';
+        $items[$id][$delta]['safe_value'] = isset($item['value']) ? _text_sanitize($instances[$id], $langcode, $entity_type, $entity, $item, 'value') : '';
         if ($field['type'] == 'text_with_summary') {
-          $items[$id][$delta]['safe_summary'] = isset($item['summary']) ? _text_sanitize($instances[$id], $langcode, $item, 'summary') : '';
+          $items[$id][$delta]['safe_summary'] = isset($item['summary']) ? _text_sanitize($instances[$id], $langcode, $entity_type, $entity, $item, 'summary') : '';
         }
       }
     }
@@ -315,7 +315,7 @@ function text_field_formatter_view($enti
     case 'text_default':
     case 'text_trimmed':
       foreach ($items as $delta => $item) {
-        $output = _text_sanitize($instance, $langcode, $item, 'value');
+        $output = _text_sanitize($instance, $langcode, $entity_type, $entity, $item, 'value');
         if ($display['type'] == 'text_trimmed') {
           $output = text_summary($output, $instance['settings']['text_processing'] ? $item['format'] : NULL, $display['settings']['trim_length']);
         }
@@ -326,10 +326,10 @@ function text_field_formatter_view($enti
     case 'text_summary_or_trimmed':
       foreach ($items as $delta => $item) {
         if (!empty($item['summary'])) {
-          $output = _text_sanitize($instance, $langcode, $item, 'summary');
+          $output = _text_sanitize($instance, $langcode, $entity_type, $entity, $item, 'summary');
         }
         else {
-          $output = _text_sanitize($instance, $langcode, $item, 'value');
+          $output = _text_sanitize($instance, $langcode, $entity_type, $entity, $item, 'value');
           $output = text_summary($output, $instance['settings']['text_processing'] ? $item['format'] : NULL, $display['settings']['trim_length']);
         }
         $element[$delta] = array('#markup' => $output);
@@ -355,7 +355,11 @@ function text_field_formatter_view($enti
  * @param $instance
  *   The instance definition.
  * @param $langcode
- *  The language associated to $item.
+ *   The language associated to $item.
+ * @param $entity_type
+ *   The entity type to sanitize, used for contextual data.
+ * @param $entity
+ *   The entity to sanitize, used for contextual data.
  * @param $item
  *   The field value to sanitize.
  * @param $column
@@ -364,13 +368,13 @@ function text_field_formatter_view($enti
  * @return
  *  The sanitized string.
  */
-function _text_sanitize($instance, $langcode, $item, $column) {
+function _text_sanitize($instance, $langcode, $entity_type, $entity, $item, $column) {
   // If the value uses a cacheable text format, text_field_load() precomputes
   // the sanitized string.
   if (isset($item["safe_$column"])) {
     return $item["safe_$column"];
   }
-  return $instance['settings']['text_processing'] ? check_markup($item[$column], $item['format'], $langcode) : check_plain($item[$column]);
+  return $instance['settings']['text_processing'] ? check_markup($item[$column], $item['format'], array('langcode' => $langcode, 'type' => $type, 'object' => $entity)) : check_plain($item[$column]);
 }
 
 /**
Index: modules/filter/filter.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.api.php,v
retrieving revision 1.20
diff -u -p -r1.20 filter.api.php
--- modules/filter/filter.api.php	26 Jun 2010 01:55:29 -0000	1.20
+++ modules/filter/filter.api.php	20 Aug 2010 04:29:44 -0000
@@ -40,6 +40,12 @@
  *     content before the actual filtering happens.
  *   - 'process callback': The name the function that performs the actual
  *     filtering.
+ *   Additional contextual data may be provided to the prepare callback and the
+ *   process callback by adding another callback:
+ *   - 'context callback': The name of a function that extracts contextual data
+ *     from the object of the filtering. For example, a filter that uses the
+ *     name of the author of a node would use this to provide the name of the
+ *     author as context to the filter.
  *
  * Filtering is a two-step process. First, the content is 'prepared' by calling
  * the 'prepare callback' function for every filter. The purpose of the 'prepare
@@ -107,12 +113,23 @@
  * - $text: The text to be filtered.
  * - $filter: The filter object containing settings for the given format.
  * - $format: The format object of the text to be filtered.
- * - $langcode: (optional) The language code of the text to be filtered.
+ * - $context: The contextual data for the text to be filtered, including the
+ *   language code and any context provided in a 'context callback'.
  * - $cache: Boolean whether check_markup() will cache the filtered $text in
  *   {cache_filter}.
  * - $cache_id: The cache ID used for $text in {cache_filter} when $cache is
  *   TRUE.
  *
+ * 'context callback' is invoked with the following arguments:
+ * - $text: The text to be filtered.
+ * - $filter: The filter object containing settings for the given format.
+ * - $format: The format object of the text to be filtered.
+ * - $type: The type of contextual object being passed in. May be an empty
+ *   string if there is no context.
+ * - $object: An object of the type specified by $type. For example, may
+ *   contain a node object, a block object, a user object, or a comment object.
+ *   May be NULL if there is no context.
+ *
  * @see check_markup()
  *
  * 'prepare callback' and 'process callback' functions may access the filter
@@ -142,10 +159,12 @@
  *   - 'title': (required) The administrative title of the filter.
  *   - 'description': A short, administrative description of what this filter
  *     does.
- *   - 'prepare callback': A callback function to call in the 'prepare' step
+ *   - 'prepare callback': The callback function to call in the 'prepare' step
+ *     of the filtering.
+ *   - 'process callback': The callback function to call in the 'process' step
  *     of the filtering.
- *   - 'process callback': (required) The callback function to call in the
- *     'process' step of the filtering.
+ *   - 'context callback': The callback function used to provide contextual
+ *     data to the prepare callback and the process callback.
  *   - 'settings callback': A callback function that provides form controls
  *     for the filter's settings. Each filter should apply either the default
  *     settings or the configured settings contained in $filter->settings. The
Index: modules/filter/filter.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v
retrieving revision 1.339
diff -u -p -r1.339 filter.module
--- modules/filter/filter.module	20 Aug 2010 01:29:55 -0000	1.339
+++ modules/filter/filter.module	20 Aug 2010 04:29:45 -0000
@@ -666,28 +666,58 @@ function filter_list_format($format_id) 
  * @param $format_id
  *   The format id of the text to be filtered. If no format is assigned, the
  *   fallback format will be used.
- * @param $langcode
- *   Optional: the language code of the text to be filtered, e.g. 'en' for
- *   English. This allows filters to be language aware so language specific
- *   text replacement can be implemented.
- * @param $cache
- *   Boolean whether to cache the filtered output in the {cache_filter} table.
- *   The caller may set this to FALSE when the output is already cached
- *   elsewhere to avoid duplicate cache lookups and storage.
+ * @param $options
+ *   An associative array of options, used to override the defaults. Possible
+ *   values include:
+ *    - cache: Boolean whether to cache the filtered output in the
+ *      {cache_filter} table. The caller may set this to TRUE when the output
+ *      is not being cached elsewhere. Otherwise, this should be left as FALSE
+ *      to avoid duplicate cache lookups and storage. Defaults to FALSE.
+ *    - langcode: the language code of the text to be filtered, e.g. 'en' for
+ *      English. This allows filters to be language aware so language specific
+ *      text replacement can be implemented. Defaults to ''.
+ *    - object: an object from which contextual data can be pulled, such as a
+ *      node object, a user object, or a block. Defaults to NULL for no context.
+ *    - type: a string that identifies the type of object, such as 'node', or
+ *      'user', or 'block'. Defaults to '' for no context.
  *
  * @ingroup sanitization
  */
-function check_markup($text, $format_id = NULL, $langcode = '', $cache = FALSE) {
+function check_markup($text, $format_id = NULL, $options = array()) {
+  $options += array(
+    'cache' => FALSE,
+    'langcode' => '',
+    'object' => NULL,
+    'type' => '',
+  );
   if (empty($format_id)) {
     $format_id = filter_fallback_format();
   }
   $format = filter_format_load($format_id);
 
   // Check for a cached version of this piece of text.
-  $cache = $cache && !empty($format->cache);
+  $cache = $options['cache'] && !empty($format->cache);
   $cache_id = '';
+
+  // Get a complete list of filters, ordered properly.
+  $filters = filter_list_format($format->format);
+  $filter_info = filter_get_filters();
+
+  $context = array(
+    'langcode' => $options['langcode'],
+  );
+  foreach ($filters as $name => $filter) {
+    if ($filter->status && isset($filter_info[$name]['context callback']) && function_exists($filter_info[$name]['context callback'])) {
+      $function = $filter_info[$name]['context callback'];
+      $result = $function($text, $filter, $format, $options['type'], $options['object']);
+      if (is_array($result)) {
+        $context += $result;
+      }
+    }
+  }
+
   if ($cache) {
-    $cache_id = $format->format . ':' . $langcode . ':' . hash('sha256', $text);
+    $cache_id = $format->format . ':' . hash('sha256', serialize($context)) . ':' . hash('sha256', $text);
     if ($cached = cache_get($cache_id, 'cache_filter')) {
       return $cached->data;
     }
@@ -697,15 +727,11 @@ function check_markup($text, $format_id 
   // need to deal with one possibility.
   $text = str_replace(array("\r\n", "\r"), "\n", $text);
 
-  // Get a complete list of filters, ordered properly.
-  $filters = filter_list_format($format->format);
-  $filter_info = filter_get_filters();
-
   // Give filters the chance to escape HTML-like data such as code or formulas.
   foreach ($filters as $name => $filter) {
     if ($filter->status && isset($filter_info[$name]['prepare callback']) && function_exists($filter_info[$name]['prepare callback'])) {
       $function = $filter_info[$name]['prepare callback'];
-      $text = $function($text, $filter, $format, $langcode, $cache, $cache_id);
+      $text = $function($text, $filter, $format, $context, $cache, $cache_id);
     }
   }
 
@@ -713,7 +739,7 @@ function check_markup($text, $format_id 
   foreach ($filters as $name => $filter) {
     if ($filter->status && isset($filter_info[$name]['process callback']) && function_exists($filter_info[$name]['process callback'])) {
       $function = $filter_info[$name]['process callback'];
-      $text = $function($text, $filter, $format, $langcode, $cache, $cache_id);
+      $text = $function($text, $filter, $format, $context, $cache, $cache_id);
     }
   }
 
Index: modules/filter/filter.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.test,v
retrieving revision 1.71
diff -u -p -r1.71 filter.test
--- modules/filter/filter.test	5 Aug 2010 23:53:38 -0000	1.71
+++ modules/filter/filter.test	20 Aug 2010 04:29:46 -0000
@@ -1322,3 +1322,80 @@ class FilterHooksTestCase extends Drupal
   }
 }
 
+/**
+ * Tests the filter system's contextual data handling.
+ */
+class FilterContextTestCase extends DrupalWebTestCase {
+  protected $format_id;
+
+  public static function getInfo() {
+    return array(
+	  'name' => 'Filter context',
+	  'description' => 'Tests the ability of the filtering system to incorporate textual data.',
+	  'group' => 'Filter',
+	);
+  }
+
+  function setUp() {
+    parent::setUp('filter_test_2');
+    $admin_user = $this->drupalCreateUser(array('administer filters'));
+    $this->drupalLogin($admin_user);
+    $format_name = $this->randomName();
+    $this->drupalPost('admin/config/content/formats/add', array('name' => $format_name, 'filters[filter_test_2_context][status]' => TRUE), t('Save configuration'));
+    $this->drupalLogout();
+    $this->format_id = db_query("SELECT format FROM {filter_format} WHERE name = :name", array(':name' => $format_name))->fetchField();
+    filter_formats_reset();
+  }
+
+  /**
+   * Test to make sure that filters are able to use contextual data, and that
+   * the caching system works properly with contextual data changes.
+   */
+  function testFilterContext() {
+    $text1 = $this->randomName();
+    $text2 = $this->randomName();
+    $var1 = (object)array('one' => $this->randomName());
+    $var2 = (object)array('one' => $this->randomName());
+
+    // Text 1 with object 1.
+    $result1 = check_markup($text1, $this->format_id, array('cache' => TRUE, 'type' => 'test', 'object' => $var1));
+    list($success, $text, $var, $rand1) = explode('/', $result1);
+    $this->assertEqual($success, 'Success', 'Context successfully passed.');
+    $this->assertEqual($text, $text1, 'Text matched.');
+    $this->assertEqual($var, $var1->one, 'Contextual variable matched.');
+    $rand_store[] = $rand1;
+
+    // Text 1 with object 1 again - make sure random variable stays the same.
+    $result2 = check_markup($text1, $this->format_id, array('cache' => TRUE, 'type' => 'test', 'object' => $var1));
+    list($success, $text, $var, $rand2) = explode('/', $result2);
+    $this->assertEqual($success, 'Success', 'Context successfully passed.');
+    $this->assertEqual($text, $text1, 'Text matched.');
+    $this->assertEqual($var, $var1->one, 'Contextual variable matched.');
+    $this->assertEqual($rand1, $rand2, 'Filter with contextual data was successfully cached.');
+
+    // Text 1 with object 2 - make sure cache invalidates.
+    $result3 = check_markup($text1, $this->format_id, array('cache' => TRUE, 'type' => 'test', 'object' => $var2));
+    list($success, $text, $var, $rand3) = explode('/', $result3);
+    $this->assertEqual($success, 'Success', 'Context successfully passed.');
+    $this->assertEqual($text, $text1, 'Text matched.');
+    $this->assertEqual($var, $var2->one, 'Contextual variable matched.');
+    $this->assertNotEqual($rand1, $rand3, 'Filter with contextual data successfully invalidated cache.');
+
+    // Back to text 1 with object 1 - cache should still be valid.
+    $result4 = check_markup($text1, $this->format_id, array('cache' => TRUE, 'type' => 'test', 'object' => $var1));
+    list($success, $text, $var, $rand4) = explode('/', $result4);
+    $this->assertEqual($success, 'Success', 'Context successfully passed.');
+    $this->assertEqual($text, $text1, 'Text matched.');
+    $this->assertEqual($var, $var1->one, 'Contextual variable matched.');
+    $this->assertEqual($rand1, $rand4, 'Filter with contextual data did not have cache invalidated.');
+
+    // Text 2 with object 2 - should be entirely new data.
+    $result5 = check_markup($text2, $this->format_id, array('cache' => TRUE, 'type' => 'test', 'object' => $var2));
+    list($success, $text, $var, $rand5) = explode('/', $result5);
+    $this->assertEqual($success, 'Success', 'Context successfully passed.');
+    $this->assertEqual($text, $text2, 'Text matched.');
+    $this->assertEqual($var, $var2->one, 'Contextual variable matched.');
+    $this->assertNotEqual($rand1, $rand5, 'No cache mix-up.');
+    $this->assertNotEqual($rand3, $rand5, 'No cache mix-up.');
+  }
+}
Index: modules/node/node.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.api.php,v
retrieving revision 1.71
diff -u -p -r1.71 node.api.php
--- modules/node/node.api.php	17 Aug 2010 16:20:08 -0000	1.71
+++ modules/node/node.api.php	20 Aug 2010 04:29:47 -0000
@@ -629,7 +629,7 @@ function hook_node_update_index($node) {
   $text = '';
   $comments = db_query('SELECT subject, comment, format FROM {comment} WHERE nid = :nid AND status = :status', array(':nid' => $node->nid, ':status' => COMMENT_PUBLISHED));
   foreach ($comments as $comment) {
-    $text .= '<h2>' . check_plain($comment->subject) . '</h2>' . check_markup($comment->comment, $comment->format, '', TRUE);
+    $text .= '<h2>' . check_plain($comment->subject) . '</h2>' . check_markup($comment->comment, $comment->format, array('cache' => TRUE, 'type' => 'comment', 'object' => $comment));
   }
   return $text;
 }
Index: modules/profile/profile.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/profile/profile.module,v
retrieving revision 1.292
diff -u -p -r1.292 profile.module
--- modules/profile/profile.module	10 Jul 2010 01:44:28 -0000	1.292
+++ modules/profile/profile.module	20 Aug 2010 04:29:47 -0000
@@ -287,7 +287,7 @@ function profile_view_field($account, $f
   if (isset($account->{$field->name}) && $value = $account->{$field->name}) {
     switch ($field->type) {
       case 'textarea':
-        return check_markup($value, filter_default_format($account), '', TRUE);
+        return check_markup($value, filter_default_format($account), array('cache' => TRUE, 'type' => 'user', 'object' => $account));
       case 'textfield':
       case 'selection':
         return $browse ? l($value, 'profile/' . $field->name . '/' . $value) : check_plain($value);
Index: modules/simpletest/tests/filter_test_2.info
===================================================================
RCS file: modules/simpletest/tests/filter_test_2.info
diff -N modules/simpletest/tests/filter_test_2.info
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/simpletest/tests/filter_test_2.info	20 Aug 2010 04:29:47 -0000
@@ -0,0 +1,8 @@
+; $Id$
+name = Filter test module (2)
+description = Tests filter system contextual data handling.
+package = Testing
+version = VERSION
+core = 7.x
+files[] = filter_test_2.module
+hidden = TRUE
Index: modules/simpletest/tests/filter_test_2.module
===================================================================
RCS file: modules/simpletest/tests/filter_test_2.module
diff -N modules/simpletest/tests/filter_test_2.module
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/simpletest/tests/filter_test_2.module	20 Aug 2010 04:29:47 -0000
@@ -0,0 +1,43 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Test module for Filter module contextual data handling..
+ */
+
+/**
+ * Implements hook_filter_info().
+ */
+function filter_test_2_filter_info() {
+  $filters['filter_test_2_context'] = array(
+    'title' => 'Contextual-data filter',
+    'description' => 'Displays based on contextual data.',
+    'process callback' => '_filter_test_2_process',
+    'context callback' => '_filter_test_2_context',
+  );
+  return $filters;
+}
+
+/**
+ * Filter process callback.
+ */
+function _filter_test_2_process($text, $filter, $format, $context, $cache, $cache_id) {
+  if (isset($context['filter_test_2'])) {
+    return 'Success/' . $text . '/' . $context['filter_test_2'] . '/' . mt_rand();
+  }
+  else {
+    return 'Failure/' . $text . '//' . mt_rand();
+  }
+}
+
+/**
+ * Filter context callback.
+ */
+function _filter_test_2_context($text, $filter, $format, $type, $object) {
+  if ($type == 'test' && !empty($object->one)) {
+    return array(
+      'filter_test_2' => $object->one,
+    );
+  }
+}
Index: modules/taxonomy/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.602
diff -u -p -r1.602 taxonomy.module
--- modules/taxonomy/taxonomy.module	17 Aug 2010 16:20:08 -0000	1.602
+++ modules/taxonomy/taxonomy.module	20 Aug 2010 04:29:48 -0000
@@ -615,7 +615,7 @@ function taxonomy_term_view($term, $view
   $build += field_attach_view('taxonomy_term', $term, $view_mode);
 
   $build['description'] = array(
-    '#markup' => check_markup($term->description, $term->format, '', TRUE),
+    '#markup' => check_markup($term->description, $term->format, array('cache' => TRUE, 'type' => 'taxonomy_term', 'object' => $term)),
     '#weight' => 0,
     '#prefix' => '<div class="taxonomy-term-description">',
     '#suffix' => '</div>',
Index: modules/taxonomy/taxonomy.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.pages.inc,v
retrieving revision 1.52
diff -u -p -r1.52 taxonomy.pages.inc
--- modules/taxonomy/taxonomy.pages.inc	3 Aug 2010 02:02:02 -0000	1.52
+++ modules/taxonomy/taxonomy.pages.inc	20 Aug 2010 04:29:48 -0000
@@ -64,7 +64,7 @@ function taxonomy_term_feed($term) {
   $channel['title'] = variable_get('site_name', 'Drupal') . ' - ' . $term->name;
   // Only display the description if we have a single term, to avoid clutter and confusion.
   // HTML will be removed from feed description.
-  $channel['description'] = check_markup($term->description, $term->format, '', TRUE);
+  $channel['description'] = check_markup($term->description, $term->format, array('cache' => TRUE, 'type' => 'taxonomy_term', 'object' => $term));
   $nids = taxonomy_select_nodes($term->tid, FALSE, variable_get('feed_default_items', 10));
 
   node_feed($nids, $channel);
Index: modules/taxonomy/taxonomy.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.test,v
retrieving revision 1.88
diff -u -p -r1.88 taxonomy.test
--- modules/taxonomy/taxonomy.test	8 Aug 2010 02:06:56 -0000	1.88
+++ modules/taxonomy/taxonomy.test	20 Aug 2010 04:29:48 -0000
@@ -1009,7 +1009,7 @@ class TaxonomyTokenReplaceTestCase exten
     $tests = array();
     $tests['[term:tid]'] = $term1->tid;
     $tests['[term:name]'] = check_plain($term1->name);
-    $tests['[term:description]'] = check_markup($term1->description, $term1->format);
+    $tests['[term:description]'] = check_markup($term1->description, $term1->format, array('type' => 'taxonomy_term', 'object' => $term1));
     $tests['[term:url]'] = url('taxonomy/term/' . $term1->tid, array('absolute' => TRUE));
     $tests['[term:node-count]'] = 0;
     $tests['[term:parent:name]'] = '[term:parent:name]';
@@ -1024,7 +1024,7 @@ class TaxonomyTokenReplaceTestCase exten
     $tests = array();
     $tests['[term:tid]'] = $term2->tid;
     $tests['[term:name]'] = check_plain($term2->name);
-    $tests['[term:description]'] = check_markup($term2->description, $term2->format);
+    $tests['[term:description]'] = check_markup($term2->description, $term2->format, array('type' => 'taxonomy_term', 'object' => $term2));
     $tests['[term:url]'] = url('taxonomy/term/' . $term2->tid, array('absolute' => TRUE));
     $tests['[term:node-count]'] = 1;
     $tests['[term:parent:name]'] = check_plain($term1->name);
Index: modules/taxonomy/taxonomy.tokens.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.tokens.inc,v
retrieving revision 1.9
diff -u -p -r1.9 taxonomy.tokens.inc
--- modules/taxonomy/taxonomy.tokens.inc	8 Aug 2010 02:06:56 -0000	1.9
+++ modules/taxonomy/taxonomy.tokens.inc	20 Aug 2010 04:29:48 -0000
@@ -107,7 +107,7 @@ function taxonomy_tokens($type, $tokens,
           break;
 
         case 'description':
-          $replacements[$original] = $sanitize ? check_markup($term->description, $term->format, '', TRUE) : $term->description;
+          $replacements[$original] = $sanitize ? check_markup($term->description, $term->format, array('cache' => TRUE, 'type' => 'taxonomy_term', 'object' => $term)) : $term->description;
           break;
 
         case 'url':
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.1193
diff -u -p -r1.1193 user.module
--- modules/user/user.module	15 Aug 2010 01:49:45 -0000	1.1193
+++ modules/user/user.module	20 Aug 2010 04:29:50 -0000
@@ -3243,7 +3243,7 @@ function user_comment_view($comment) {
     //   hypothetical process of loading, viewing, and saving will hijack the
     //   stored data. Consider renaming to $comment->signature_safe or similar
     //   here and elsewhere in Drupal 8.
-    $comment->signature = check_markup($comment->signature, $comment->signature_format, '', TRUE);
+    $comment->signature = check_markup($comment->signature, $comment->signature_format, array('cache' => TRUE, 'type' => 'comment', 'object' => $comment));
   }
   else {
     $comment->signature = '';
Index: modules/user/user.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.test,v
retrieving revision 1.100
diff -u -p -r1.100 user.test
--- modules/user/user.test	5 Aug 2010 23:53:39 -0000	1.100
+++ modules/user/user.test	20 Aug 2010 04:29:51 -0000
@@ -1520,7 +1520,7 @@ class UserSignatureTestCase extends Drup
     // Assert that the signature did not make it through unfiltered.
     $this->drupalGet('node/' . $node->nid);
     $this->assertNoRaw($signature_text, 'Unfiltered signature text not found.');
-    $this->assertRaw(check_markup($signature_text, $this->plain_text_format->format), 'Filtered signature text found.');
+    $this->assertRaw(check_markup($signature_text, $this->plain_text_format->format, array('type' => 'comment', 'object' => comment_load($comment_id))), 'Filtered signature text found.');
   }
 }
 
