From f8be42421c636bd7c6ace9bb051275214e23646d Mon Sep 17 00:00:00 2001
From: Stefan Borchert <stefan.borchert@undpaul.de>, Morten Fangel <fangel@sevengoslings.net>, adorsk <adorsk@gmail.com>, Joachim Noreiko <joachim@107701.no-reply.drupal.org>
Date: Fri, 8 Jul 2011 11:11:32 +0200
Subject: [PATCH] Issue #1000736: Taxonomy autocomplete and commas.

---
 modules/taxonomy/taxonomy.pages.inc |    7 +++----
 modules/taxonomy/taxonomy.test      |    4 ++--
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/modules/taxonomy/taxonomy.pages.inc b/modules/taxonomy/taxonomy.pages.inc
index 3aed290..24e0a01 100644
--- a/modules/taxonomy/taxonomy.pages.inc
+++ b/modules/taxonomy/taxonomy.pages.inc
@@ -110,7 +110,7 @@ function taxonomy_autocomplete($field_name, $tags_typed = '') {
       ->execute()
       ->fetchAllKeyed();
 
-    $prefix = count($tags_typed) ? implode(', ', $tags_typed) . ', ' : '';
+    $prefix = count($tags_typed) ? drupal_implode_tags($tags_typed) . ', ' : '';
 
     $term_matches = array();
     foreach ($tags_return as $tid => $name) {
@@ -119,9 +119,8 @@ function taxonomy_autocomplete($field_name, $tags_typed = '') {
       if (strpos($name, ',') !== FALSE || strpos($name, '"') !== FALSE) {
         $n = '"' . str_replace('"', '""', $name) . '"';
       }
-      else {
-        $term_matches[$prefix . $n] = check_plain($name);
-      }
+      // Add term name to list of matches.
+      $term_matches[$prefix . $n] = check_plain($name);
     }
   }
 
diff --git a/modules/taxonomy/taxonomy.test b/modules/taxonomy/taxonomy.test
index 80ddc84..3baf788 100644
--- a/modules/taxonomy/taxonomy.test
+++ b/modules/taxonomy/taxonomy.test
@@ -580,7 +580,7 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
     field_create_instance($instance);
     $terms = array(
       $this->randomName(),
-      $this->randomName(),
+      $this->randomName() . ', ' . $this->randomName(),
       $this->randomName(),
     );
 
@@ -590,7 +590,7 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
     $edit["body[$langcode][0][value]"] = $this->randomName();
     // Insert the terms in a comma separated list. Vocabulary 1 is a
     // free-tagging field created by the default profile.
-    $edit[$instance['field_name'] . "[$langcode]"] = implode(', ', $terms);
+    $edit[$instance['field_name'] . "[$langcode]"] = drupal_implode_tags($terms);
 
     // Preview and verify the terms appear but are not created.
     $this->drupalPost('node/add/page', $edit, t('Preview'));
-- 
1.7.4

