From 9dfbc063653c729f7a74f1e02260073594fd66fa Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 26 Oct 2015 17:03:58 +0300 Subject: allow empty tags --- src/main/java/com/juick/http/www/NewMessage.java | 32 +++++++++++------------- 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'src/main/java/com/juick/http/www') diff --git a/src/main/java/com/juick/http/www/NewMessage.java b/src/main/java/com/juick/http/www/NewMessage.java index 34733511..e2fe9629 100644 --- a/src/main/java/com/juick/http/www/NewMessage.java +++ b/src/main/java/com/juick/http/www/NewMessage.java @@ -141,27 +141,23 @@ public class NewMessage { body = body.replace("\r", ""); String tagsStr = request.getParameter("tags"); - if (tagsStr == null || tagsStr.isEmpty()) { - response.sendError(400); - return; - } - String tagsArr[] = tagsStr.split("[ \\,]"); - for (int i = 0; i < tagsArr.length; i++) { - if (tagsArr[i].startsWith("*")) { - tagsArr[i] = tagsArr[i].substring(1); + ArrayList tags = new ArrayList(); + String tagsArr[] = new String[1]; + if (tagsStr != null && !tagsStr.isEmpty()) { + tagsArr = tagsStr.split("[ \\,]"); + for (int i = 0; i < tagsArr.length; i++) { + if (tagsArr[i].startsWith("*")) { + tagsArr[i] = tagsArr[i].substring(1); + } + if (tagsArr[i].length() > 64) { + tagsArr[i] = tagsArr[i].substring(0, 64); + } } - if (tagsArr[i].length() > 64) { - tagsArr[i] = tagsArr[i].substring(0, 64); + tags = TagQueries.getTags(sql, tagsArr, true); + while (tags.size() > 5) { + tags.remove(5); } } - ArrayList tags = TagQueries.getTags(sql, tagsArr, true); - if (tags.isEmpty()) { - response.sendError(400); - return; - } - while (tags.size() > 5) { - tags.remove(5); - } String attachmentFName = null; try { -- cgit v1.2.3