Browse Source

Merge pull request #4574 from FreddleSpl0it/tag-fix

[Web] domain/mailbox tagging check for empty tags
Niklas Meyer 3 years ago
parent
commit
d2a6838958
2 changed files with 8 additions and 2 deletions
  1. 7 2
      data/web/inc/functions.mailbox.inc.php
  2. 1 0
      data/web/js/build/014-mailcow.js

+ 7 - 2
data/web/inc/functions.mailbox.inc.php

@@ -568,6 +568,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
           ));
           ));
           // save tags
           // save tags
           foreach($tags as $index => $tag){
           foreach($tags as $index => $tag){
+            if (empty($tag)) continue;
             if ($index > $GLOBALS['TAGGING_LIMIT']) {
             if ($index > $GLOBALS['TAGGING_LIMIT']) {
               $_SESSION['return'][] = array(
               $_SESSION['return'][] = array(
                 'type' => 'warning',
                 'type' => 'warning',
@@ -1124,6 +1125,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
           ));
           ));
           // save tags
           // save tags
           foreach($tags as $index => $tag){
           foreach($tags as $index => $tag){
+            if (empty($tag)) continue;
             if ($index > $GLOBALS['TAGGING_LIMIT']) {
             if ($index > $GLOBALS['TAGGING_LIMIT']) {
               $_SESSION['return'][] = array(
               $_SESSION['return'][] = array(
                 'type' => 'warning',
                 'type' => 'warning',
@@ -2201,8 +2203,9 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
                 ':gal' => $gal,
                 ':gal' => $gal,
                 ':domain' => $domain
                 ':domain' => $domain
               ));
               ));
-              // save tags, tag_name is unique
+              // save tags
               foreach($tags as $index => $tag){
               foreach($tags as $index => $tag){
+                if (empty($tag)) continue;
                 if ($index > $GLOBALS['TAGGING_LIMIT']) {
                 if ($index > $GLOBALS['TAGGING_LIMIT']) {
                   $_SESSION['return'][] = array(
                   $_SESSION['return'][] = array(
                     'type' => 'warning',
                     'type' => 'warning',
@@ -2368,8 +2371,9 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
                 ':description' => $description,
                 ':description' => $description,
                 ':domain' => $domain
                 ':domain' => $domain
               ));
               ));
-              // save tags, tag_name is unique
+              // save tags
               foreach($tags as $index => $tag){
               foreach($tags as $index => $tag){
+                if (empty($tag)) continue;
                 if ($index > $GLOBALS['TAGGING_LIMIT']) {
                 if ($index > $GLOBALS['TAGGING_LIMIT']) {
                   $_SESSION['return'][] = array(
                   $_SESSION['return'][] = array(
                     'type' => 'warning',
                     'type' => 'warning',
@@ -2712,6 +2716,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
             ));
             ));
             // save tags
             // save tags
             foreach($tags as $index => $tag){
             foreach($tags as $index => $tag){
+              if (empty($tag)) continue;
               if ($index > $GLOBALS['TAGGING_LIMIT']) {
               if ($index > $GLOBALS['TAGGING_LIMIT']) {
                 $_SESSION['return'][] = array(
                 $_SESSION['return'][] = array(
                   'type' => 'warning',
                   'type' => 'warning',

+ 1 - 0
data/web/js/build/014-mailcow.js

@@ -290,6 +290,7 @@ $(document).ready(function() {
     var tagValuesElem = $(tagboxElem).find(".tag-values")[0];
     var tagValuesElem = $(tagboxElem).find(".tag-values")[0];
 
 
     var tag = escapeHtml($(tagInputElem).val());
     var tag = escapeHtml($(tagInputElem).val());
+    if (!tag) return;
     var value_tags = [];
     var value_tags = [];
     try {
     try {
       value_tags = JSON.parse($(tagValuesElem).val());
       value_tags = JSON.parse($(tagValuesElem).val());