From 2aabcb6aaf85bcbda0f04a9297109b93ae279b32 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 7 Nov 2008 18:52:18 +0000 Subject: - Patch #173826 by Jody Lynn, catch, roychri, arcX: trim taxonomy term names upon save. --- modules/taxonomy/taxonomy.module | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'modules/taxonomy/taxonomy.module') diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 5f61fc863..5dc0771bb 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -209,12 +209,17 @@ function taxonomy_admin_vocabulary_title_callback($vocabulary) { } /** - * 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_hierarchy($vocabulary, $changed_term) { * 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'); -- cgit v1.2.3