From 92d894783e78d1f471af891ff80daf3c3fd97cae Mon Sep 17 00:00:00 2001 From: Tobias Reich Date: Fri, 18 Apr 2014 21:27:52 +0200 Subject: [PATCH] Improved parsing of tags --- assets/js/photo.js | 2 +- php/modules/Photo.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/js/photo.js b/assets/js/photo.js index a6f5d98..ef90cf8 100644 --- a/assets/js/photo.js +++ b/assets/js/photo.js @@ -408,7 +408,7 @@ photo = { // Parse tags tags = tags.replace(/(\ ,\ )|(\ ,)|(,\ )|(,{1,}\ {0,})|(,$|^,)/g, ','); - tags = tags.replace(/,$|^,/g, ''); + tags = tags.replace(/,$|^,|(\ ){0,}$/g, ''); if (visible.photo()) { photo.json.tags = tags; diff --git a/php/modules/Photo.php b/php/modules/Photo.php index d43f094..76e44b0 100755 --- a/php/modules/Photo.php +++ b/php/modules/Photo.php @@ -639,7 +639,7 @@ class Photo extends Module { # Parse tags $tags = preg_replace('/(\ ,\ )|(\ ,)|(,\ )|(,{1,}\ {0,})|(,$|^,)/', ',', $tags); - $tags = preg_replace('/,$|^,/', ',', $tags); + $tags = preg_replace('/,$|^,|(\ ){0,}$/', '', $tags); if (strlen($tags)>1000) return false; # Set tags