diff -up ./flashvideo.module.unicode ./flashvideo.module
--- ./flashvideo.module.unicode	2009-08-17 00:08:30.000000000 +0200
+++ ./flashvideo.module	2009-10-15 01:23:59.000000000 +0200
@@ -2178,87 +2178,6 @@ function flashvideo_get_thumbnail_file($
 }
 
 /**
- *  Parses all of the tags, and places them in a parameters array.
- *
- *  @param  $body
- *   The string of the body of the node.
- *
- *  @param  $pos
- *   A reference to the current location of the character pointer in the node body.
- *
- *  @param  $max_params
- *   The maximum amount of allowed parameters.
- *
- *  @return
- *   An array of the parameters with their associated values.
- */
-function _flashvideo_parse_params($body, &$pos, $max_params = 10) {
-
-  // If we are able to find the end tag delimiter denoted by "]"
-  if (($endpos = strpos($body, ']', $pos)) !== FALSE) {
-
-    // Set up an array of characters to take out from the parameter string.
-    $bad_chars = array("<p>", "</p>", "<br>", "<br />", "\n", "\r", "\t", " ");
-
-    // Get our parameter string.
-    $param_string = drupal_substr($body, $pos, ($endpos - $pos));
-
-    // Replace all bad characters with null chars.
-    $param_string = str_replace($bad_chars, '', $param_string);
-
-    // Create an array with all parameters.
-    $parts = explode(':', $param_string);
-
-    // Set the position to the end position.
-    $pos = $endpos + 1;
-
-    // Remove the first index (it's not a parameter).
-    unset($parts[0]);
-    $parts = array_values($parts);
-
-    // If there are parameters provided, and they don't exceed the maximum...
-    if ((count($parts) > 0) && (count($parts) < $max_params)) {
-      $params = array();
-
-      // Loop through all of our parameters.
-      foreach ($parts as $part) {
-
-        // Get the value and parameter for this part.
-        $sub_parts = explode('=', $part);
-
-        // The parameter needs to be all lower case.
-        $sub_parts[0] = drupal_strtolower($sub_parts[0]);
-
-        // If they actually provided a "param=value"
-        if ((drupal_strlen($sub_parts[0]) > 0) && (drupal_strlen($sub_parts[1]) > 0)) {
-
-          // Check to see if this is a FlashVar.
-          if (strpos($sub_parts[0], 'flashvar') !== FALSE) {
-
-            // If so, then split up this parameter based on the "|"
-            $flashvar = explode('|', $sub_parts[0]);
-
-            // Set the "flashvar" parameter.
-            $params['flashvars'][$flashvar[1]] = $sub_parts[1];
-          }
-          else {
-
-            // Set this parameter.
-            $params[$sub_parts[0]] = $sub_parts[1];
-          }
-        }
-      }
-
-      // Return the parameters array.
-      return $params;
-    }
-  }
-
-  // Return no parameters.
-  return array();
-}
-
-/**
  * Search and Replace routine.  Scans the body of a node and replaces every tag and its parameters with an object.
  *
  *  @param $node
@@ -2269,48 +2188,47 @@ function _flashvideo_parse_params($body,
  *
  */
 function _flashvideo_replace_tags(&$node, $tag) {
-
-  // The maximum number of parameters allowed.  All others will be ignored.
-  $max_num_params = 4;
-
   // Set the body to be modified.
   $body = (isset($node->teaser) && $node->body == '') ? $node->teaser : $node->body;
 
-  // Search for tags
-  for ($pos = 0; (($pos = $startpos = strpos($body, $tag, $pos)) !== FALSE); $pos++) {
-
-    // We need to check to see if this tag has "!" in front of it, if it does, then we will ignore this tag.
-    if (drupal_substr($body, $pos - 1, 1) == '!') {
-
-      // Replace the body with this with a normal "[video]" or "[thumbnail]"
-      $body = substr_replace($body, $tag, $pos - 1, drupal_strlen($tag) + 1);
+  $pattern = '/(!?)\[' . $tag . '(?:\s*:\s*([^=]+)=([^:\]]+))*\]/i';
+  $offset = 0;
+  while (preg_match($pattern, $body, $match, PREG_OFFSET_CAPTURE, $offset) == 1) {
+    // each match in $match consists of [ $matched_text, $offset ]
+    // $match[0] is the whole match
+    // $match[1] is the character before the [
+    // $match[n], $match[n+1] are parameter and value pairs (n=2,4,6,8,...)
+
+    $match_start = $match[0][1];
+
+    if ($match[1][0]=='!') {
+      //if the tag was escaped with a !, just remove the ! and skip over the tag
+      $match_length = 1;
+      $match_replacement = "";
+      $offset = $match_start + strlen($match[0][0]) - 1;
     }
-
-    // This is the real thing.
     else {
-
-      // So that it will skip over the "["
-      $pos++;
+      $match_length = strlen($match[0][0]);
 
       // Initialize our parameters array.
       $params = array();
-
-      // Parse all the parameters.
-      $params = _flashvideo_parse_params($body, $pos);
-
+      $maxi = count($match);
+      for ($i=2; $i<$maxi; $i=$i+2) {
+        $params[$match[$i][0]] = $match[$i+1][0];
+      }
+      
       // Set the object based on the parameters given.
-      $object = ($tag == '[thumbnail') ? flashvideo_get_thumbnail($node, $params) : flashvideo_get_video($node, $params);
+      $object = ($tag == 'thumbnail') ? flashvideo_get_thumbnail($node, $params) : flashvideo_get_video($node, $params);
 
-      // Replace this tag with the real object code.
-      $body = substr_replace($body, $object, $startpos, ($pos - $startpos));  // Replace this tag.
+      // Replace this tag with the real object code
+      $match_replacement = $object;
+      $offset = $match_start + strlen($match_replacement);
     }
 
-    // If the position exceeds the body length, then break out of the loop.
-    if ($pos >= drupal_strlen($body))
-      break;
+    $body = substr_replace($body, $match_replacement, $match_start, $match_length);
   }
 
-  // Set the teaser or the body dependent on which one is being shown.
+  // Set the teaser or the body depending on which one is being shown.
   if ((isset($node->teaser) && $node->body == ''))
     $node->teaser = $body;
   else
@@ -2425,11 +2343,11 @@ function flashvideo_nodeapi(&$node, $op,
 
         if ((!flashvideo_variable_get($node->type, 'disabletag', 0)) &&
           (!$teaser || flashvideo_variable_get($node->type, 'searchvideo', 0)))
-          _flashvideo_replace_tags($node, '[video');
+          _flashvideo_replace_tags($node, 'video');
 
         if ((!flashvideo_variable_get($node->type, 'disabletag', 0)) &&
           ($teaser || flashvideo_variable_get($node->type, 'searchthumb', 0)))
-          _flashvideo_replace_tags($node, '[thumbnail');
+          _flashvideo_replace_tags($node, 'thumbnail');
 
         break;
 
