? 922868-5_tags.patch
? 922868-6_tags.patch
Index: data_taxonomy/data_taxonomy.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/data/data_taxonomy/Attic/data_taxonomy.module,v
retrieving revision 1.1.2.40
diff -u -p -r1.1.2.40 data_taxonomy.module
--- data_taxonomy/data_taxonomy.module	14 Sep 2010 19:03:47 -0000	1.1.2.40
+++ data_taxonomy/data_taxonomy.module	28 Sep 2010 14:30:37 -0000
@@ -136,6 +136,7 @@ function _data_taxonomy_insert_terms($ta
   $tids = array();
   foreach ($terms as $term) {
     if (is_string($term)) {
+      $term = data_taxonomy_sanitize($term, $vocabulary->vid);
       $term = data_taxonomy_save_term_name($term, $vocabulary->vid, $vocabulary->tags);
     }
     else {
@@ -143,6 +144,7 @@ function _data_taxonomy_insert_terms($ta
         $term = (array)$term;
       }
       if (is_array($term)) {
+        $term['name'] = data_taxonomy_sanitize($term['name'], $vocabulary->vid);
         $term = data_taxonomy_save_term_array($term, $vocabulary->vid, $vocabulary->tags);
       }
     }
@@ -331,6 +333,18 @@ function data_taxonomy_save_term_array($
 }
 
 /**
+ * Sanitize a term name depending on its vocabulary settings.
+ */
+function data_taxonomy_sanitize($name, $vid) {
+  $vocabulary = taxonomy_vocabulary_load($vid);
+  if ($vocabulary->tags) {
+    // Make sure there aren't any terms with a comma (=tag delimiter) in it.
+    return preg_replace('/\s*,\s*/', ' ', $name);
+  }
+  return $name;
+}
+
+/**
  * Look up a term by name and vid.
  *
  * @param $name
