--- d:\0\drupal-6.x-dev\modules\taxonomy\taxonomy.pages.inc	2009-04-27 14:49:05.000000000 +0200
+++ d:\0\drupal-6.x-dev\modules\taxonomy\taxonomy.pagesNew.inc	2011-02-14 13:11:06.181822100 +0100
@@ -121,7 +121,14 @@ function taxonomy_autocomplete($vid, $st
   if ($last_string != '') {
     $result = db_query_range(db_rewrite_sql("SELECT t.tid, t.name FROM {term_data} t WHERE t.vid = %d AND LOWER(t.name) LIKE LOWER('%%%s%%')", 't', 'tid'), $vid, $last_string, 0, 10);
 
-    $prefix = count($array) ? implode(', ', $array) .', ' : '';
+    $prefix = '';
+    if ($array && is_array($array)) {
+      foreach ($array as $term)
+        if (strpos($term, ',') !== FALSE || strpos($term, '"') !== FALSE) {
+          $term = '"'. str_replace('"', '""', $term) .'"';
+        $prefix .= $term . ', ';
+      }
+    }
 
     while ($tag = db_fetch_object($result)) {
       $n = $tag->name;
