Index: codefilter.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/codefilter/codefilter.module,v
retrieving revision 1.30
diff -u -p -r1.30 codefilter.module
--- codefilter.module	7 Sep 2009 16:15:14 -0000	1.30
+++ codefilter.module	23 Aug 2010 07:39:29 -0000
@@ -29,6 +29,13 @@ function codefilter_process_php($text) {
 }
 
 /**
+ * Callback to replace content of the <?php ?> elements.
+ */
+function _codefilter_process_php_callback($matches) {
+  return codefilter_process_php($matches[1]);
+}
+
+/**
  * Helper function for codefilter_process_code().
  */
 function codefilter_process_php_inline($matches) {
@@ -65,6 +72,13 @@ function codefilter_process_code($text) 
   return str_replace("\n", '', $text);
 }
 
+/**
+ * Callback to replace content of the <code> elements.
+ */
+function _codefilter_process_code_callback($matches) {
+  return codefilter_process_code($matches[1]);
+}
+
 function codefilter_fix_spaces($text) {
   return preg_replace('@&nbsp;(?!&nbsp;)@', ' ', $text);
 }
@@ -93,6 +107,20 @@ function codefilter_escape($text, $type 
 }
 
 /**
+ * Callback to escape content of <code> elements.
+ */
+function _codefilter_escape_code_tag_callback($matches) {
+  return codefilter_escape($matches[1], 'code');
+}
+
+/**
+ * Callback to escape content of <?php ?>, [?php ?], <% %>, and [% %] elements.
+ */
+function _codefilter_escape_php_tag_callback($matches) {
+  return codefilter_escape($matches[2], 'php');
+}
+
+/**
  * Implement hook_filter_info().
  */
 function codefilter_filter_info() {
@@ -109,14 +137,14 @@ function codefilter_filter_info() {
 function _codefilter_prepare($text, $format) {
   /* Note: we replace <code> </code>, <?php ?>, [?php ?], <% %>, and [% %]
      to prevent other filters from acting on them. */
-  $text = preg_replace('@<code>(.+?)</code>@se', "codefilter_escape('$1', 'code')", $text);
-  $text = preg_replace('@[\[<](\?php|%)(.+?)(\?|%)[\]>]@se', "codefilter_escape('$2', 'php')", $text);
+  $text = preg_replace_callback('@<code>(.+?)</code>@s', '_codefilter_escape_code_tag_callback', $text);
+  $text = preg_replace_callback('@[\[<](\?php|%)(.+?)(\?|%)[\]>]@s', '_codefilter_escape_php_tag_callback', $text);
   return $text;
 }
 
 function _codefilter_process($text, $format) {
-  $text = preg_replace('@\[codefilter_code\](.+?)\[/codefilter_code\]@se', "codefilter_process_code('$1')", $text);
-  $text = preg_replace('@\[codefilter_php\](.+?)\[/codefilter_php\]@se', "codefilter_process_php('$1')", $text);
+  $text = preg_replace_callback('@\[codefilter_code\](.+?)\[/codefilter_code\]@s', '_codefilter_process_code_callback', $text);
+  $text = preg_replace_callback('@\[codefilter_php\](.+?)\[/codefilter_php\]@s', '_codefilter_process_php_callback', $text);
   return $text;
 }
 
