summaryrefslogtreecommitdiff
path: root/modules/taxonomy/taxonomy.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2008-11-07 18:52:18 +0000
committerDries Buytaert <dries@buytaert.net>2008-11-07 18:52:18 +0000
commit2aabcb6aaf85bcbda0f04a9297109b93ae279b32 (patch)
tree187d9ae22092371cccc6296850495a2f9e8419e2 /modules/taxonomy/taxonomy.module
parentaf0463c66aaeda66a078ecfda46cc81c49599859 (diff)
downloadbrdo-2aabcb6aaf85bcbda0f04a9297109b93ae279b32.tar.gz
brdo-2aabcb6aaf85bcbda0f04a9297109b93ae279b32.tar.bz2
- Patch #173826 by Jody Lynn, catch, roychri, arcX: trim taxonomy term names upon save.
Diffstat (limited to 'modules/taxonomy/taxonomy.module')
-rw-r--r--modules/taxonomy/taxonomy.module11
1 files changed, 10 insertions, 1 deletions
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');