Index: quote.module
===================================================================
--- quote.module	(revision 52)
+++ quote.module	(working copy)
@@ -240,33 +240,39 @@
  *   Filtered text.
  */
 function _quote_filter_process($text) {
-  if (stristr($text, '[quote')) {
-    // Single regexp with callback allowing for theme calls and quote
-    // nesting/recursion with regexp code from
-    // http://de.php.net/manual/en/function.preg-replace-callback.php#85836
-    $text = preg_replace_callback('#\[(quote.*?)]((?>\[(?!/?quote[^[]*?])|[^[]|(?R))*)\[/quote]#is', '_quote_filter_process_callback', $text);
+  $output = ''; // Variable used to store the output string.
+  $buffer = ''; // Buffer for all text within the [quote] tags.
+  $level = 0; // Nesting level.
+  $author = ''; // Buffer for the author.
+
+  // Process the input until the next quote tag.
+  while (preg_match('#\\[\\/?quote(?:\\=(.{1,64}?))?\\]#is', $text, $match, NULL)) {
+    $text = explode($match[0], $text, 2);
+    if ($level == 0 && !empty($match[1])) {
+      $author = trim($match[1]);
+    }
+    if ($level == 0) {
+      $output .= $text[0];
+    }
+    else {
+      $buffer .= $text[0] . $match[0];
+    }
+    // Increase the level if second char is / ("[/quote]") or decrease otherwise.
+    $level += $match[0]{1} == '/' ? -1 : 1;
+    if ($level == 0) {
+      $quote = preg_replace('#\\[\\/quote\\]$#is', '', $buffer);
+      // Process quote tags in sublevels.
+      $quote = _quote_filter_process($quote);
+      $output .= theme('quote', $quote, $author);
+      $buffer = '';
+    }
+    $text = $text[1];
   }
 
-  return $text;
-}
+  // Add the remaining input. This is the text after the last quote.
+  $output .= $text;
 
-/**
- * Generate and return the quote theming for a quote occurence found by
- * _quote_filter_process.
- *
- * @param $matches
- *   The RegExp matches (for author and quote) found in _quote_filter_process.
- *
- * @return $output_quote
- *   Themed quote.
- */
-function _quote_filter_process_callback($matches) {
-  $quote_author = trim(substr($matches[1], 6));
-  $quote_content = _quote_filter_process($matches[2]);
-
-  $quote_output = theme('quote', $quote_content, $quote_author);
-
-  return $quote_output;
+  return $output;
 }
 
 /**
