--- ./taxonomy_single_tag.module 2009-11-05 00:04:22.000000000 -0500
+++ ./taxonomy_single_tag.module  2009-11-05 00:04:50.000000000 -0500
@@ -45,6 +45,34 @@ function taxonomy_single_tag_menu() {
 }
 
 /**
+ * Implementation of hook_nodeapi().
+ */
+function taxonomy_single_tag_nodeapi($node, $op, $arg = 0) {
+  switch ($op) {
+    case 'presave':
+      if (!empty($node->taxonomy)) {
+        $terms = &$node->taxonomy['tags'];
+        // Free tagging vocabularies do not send their tids in the form,
+        // so we'll detect them here and process them independently.
+        // As only one tag is allowed commas requires quoting the phrase
+        // while quotes are double escaped.
+        if (isset($terms)) {
+          $vids_single_tag = variable_get('taxonomy_single_tag:vids', array());
+          foreach($terms as $vid => $term_name) {
+            if (in_array($vid, $vids_single_tag)) {
+              if (strpos($term_name, ',') !== FALSE || strpos($term_name, '"') !== FALSE) {
+                $term_name = '"'. str_replace('"', '""', $term_name) .'"';
+              }
+              $terms[$vid] = $term_name;
+            }
+          }
+        }
+      }
+      break;
+  }
+}
+
+/**
  * Implementation of hook_form_alter().
  */
 function taxonomy_single_tag_form_alter(&$form, $form_state, $form_id) {
@@ -56,6 +84,16 @@ function taxonomy_single_tag_form_alter(
       if (in_array($vid, $vids_single_tag)) {
         $element['#autocomplete_path'] = 'taxonomy_single_tag/autocomplete/' . $vid;
         $vocabulary = taxonomy_vocabulary_load($vid);
+        if (!empty($element['#default_value'])) {
+          $term_name = $element['#default_value'];
+          if (strpos($term_name, ',') !== FALSE || strpos($term_name, '"') !== FALSE) {
+            // remove enclosing quotes
+            $term_name = substr($term_name, 1, strlen($term_name) - 2);
+            // unescape doubled quotes
+            $term_name = str_replace('""', '"', $term_name);
+            $element['#default_value'] = $term_name;
+          }          
+        } 
         // avoid default multiple tags description 
         if (empty($vocabulary->help)) unset($element['#description']);
       }
