Index: modules/filter/filter.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v
retrieving revision 1.192
diff -u -r1.192 filter.module
--- modules/filter/filter.module	8 Dec 2007 14:06:21 -0000	1.192
+++ modules/filter/filter.module	11 Dec 2007 02:54:49 -0000
@@ -419,33 +419,39 @@
 
     // Check for a cached version of this piece of text.
     $id = $format .':'. md5($text);
-    if ($cached = cache_get($id, 'cache_filter')) {
-      return $cached->data;
-    }
-
-    // See if caching is allowed for this format.
-    $cache = filter_format_allowcache($format);
-
-    // Convert all Windows and Mac newlines to a single newline,
-    // so filters only 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);
+    
+    if ($cached = cache_get($id, 'cache_filter')) {
+      $text = $cached->data;
+    } else {
+      // See if caching is allowed for this format.
+      $cache = filter_format_allowcache($format);
+
+      // Convert all Windows and Mac newlines to a single newline,
+      // so filters only need to deal with one possibility.
+      $text = str_replace(array("\r\n", "\r"), "\n", $text);
+
+      // Give filters the chance to escape HTML-like data such as code or formulas.
+      foreach ($filters as $filter) {
+        $text = module_invoke($filter->module, 'filter', 'prepare', $filter->delta, $format, $text);
+      }
 
-    // Give filters the chance to escape HTML-like data such as code or formulas.
-    foreach ($filters as $filter) {
-      $text = module_invoke($filter->module, 'filter', 'prepare', $filter->delta, $format, $text);
-    }
+      // Perform filtering.
+      foreach ($filters as $filter) {
+        $text = module_invoke($filter->module, 'filter', 'process', $filter->delta, $format, $text);
+      }
 
-    // Perform filtering.
-    foreach ($filters as $filter) {
-      $text = module_invoke($filter->module, 'filter', 'process', $filter->delta, $format, $text);
+      // Store in cache with a minimum expiration time of 1 day.
+      if ($cache) {
+        cache_set($id, $text, 'cache_filter', time() + (60 * 60 * 24));
+      }
     }
-
-    // Store in cache with a minimum expiration time of 1 day.
-    if ($cache) {
-      cache_set($id, $text, 'cache_filter', time() + (60 * 60 * 24));
+    
+    // Post process filtering, always run regardless of caching
+    foreach ($filters as $filter) {
+      $text = module_invoke($filter->module, 'filter', 'post process', $filter->delta, $format, $text);
     }
   }
   else {
