Index: taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.438
diff -u -p -r1.438 taxonomy.module
--- taxonomy.module	5 Nov 2008 14:08:11 -0000	1.438
+++ taxonomy.module	7 Nov 2008 01:24:44 -0000
@@ -209,12 +209,17 @@ function taxonomy_admin_vocabulary_title
 }
 
 /**
- * Save a vocabulary given a vocabulary object..
+ * Save a vocabulary given a vocabulary object.
  */
 function taxonomy_vocabulary_save($vocabulary) {
   if (empty($vocabulary->nodes)) {
     $vocabulary->nodes = array();
   }
+  
+  if (!empty($vocabulary->name)) {
+    // Prevent leading and trailing spaces in vocabulary names.
+    $vocabulary->name = trim($vocabulary->name);
+  }
 
   if (!isset($vocabulary->module)) {
     $vocabulary->module = 'taxonomy';
@@ -316,6 +321,10 @@ function taxonomy_check_vocabulary_hiera
  *   Status constant indicating if term was inserted or updated.
  */
 function taxonomy_term_save($term) {
+  if ($term->name) {
+    // Prevent leading and trailing spaces in term names.
+    $term->name = trim($term->name);
+  }
 
   if (!empty($term->tid) && $term->name) {
     $status = drupal_write_record('term_data', $term, 'tid');
