aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/server
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-11-09 14:54:53 +0300
committerGravatar Vitaly Takmazov2018-11-09 14:55:47 +0300
commit4cab3d1afe4400016703ce0a8721f42823ac4e40 (patch)
tree5db050fbe070fbb0122e6dbfbea3635368e4f78f /src/main/java/com/juick/server
parent30459a25e254ab1c4046e0c96297e93ad7d4845b (diff)
CommandsManager: 4096 character limit
Diffstat (limited to 'src/main/java/com/juick/server')
-rw-r--r--src/main/java/com/juick/server/CommandsManager.java10
-rw-r--r--src/main/java/com/juick/server/api/Post.java9
2 files changed, 9 insertions, 10 deletions
diff --git a/src/main/java/com/juick/server/CommandsManager.java b/src/main/java/com/juick/server/CommandsManager.java
index 82143482..e564f18e 100644
--- a/src/main/java/com/juick/server/CommandsManager.java
+++ b/src/main/java/com/juick/server/CommandsManager.java
@@ -21,13 +21,13 @@ import com.juick.Message;
import com.juick.Tag;
import com.juick.User;
import com.juick.formatters.PlainTextFormatter;
-import com.juick.service.activities.DeleteMessageEvent;
-import com.juick.service.component.*;
import com.juick.model.CommandResult;
import com.juick.model.TagStats;
import com.juick.server.helpers.annotation.UserCommand;
import com.juick.server.util.HttpUtils;
import com.juick.service.*;
+import com.juick.service.activities.DeleteMessageEvent;
+import com.juick.service.component.*;
import com.juick.util.MessageUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@@ -110,6 +110,9 @@ public class CommandsManager {
}
// new message
String body = tags.getLeft().trim();
+ if (body.length() > 4096) {
+ return CommandResult.fromString("Sorry, 4096 characters maximum.");
+ }
boolean haveAttachment = StringUtils.isNotEmpty(attachment.toString());
String attachmentFName = null;
String attachmentType = null;
@@ -507,6 +510,9 @@ public class CommandsManager {
return CommandResult.fromString("Tags are NOT updated (5 tags maximum?)");
}
} else {
+ if (txt.length() > 4096) {
+ return CommandResult.fromString("Sorry, 4096 characters maximum.");
+ }
boolean haveAttachment = StringUtils.isNotEmpty(attachment.toString());
String attachmentFName = null;
String attachmentType = null;
diff --git a/src/main/java/com/juick/server/api/Post.java b/src/main/java/com/juick/server/api/Post.java
index 303ff109..2c7346b3 100644
--- a/src/main/java/com/juick/server/api/Post.java
+++ b/src/main/java/com/juick/server/api/Post.java
@@ -70,11 +70,8 @@ public class Post {
@RequestParam(required = false) MultipartFile attach) throws Exception {
User visitor = UserUtils.getCurrentUser();
- if (visitor.isAnonymous())
+ if (visitor.isAnonymous()) {
throw new HttpForbiddenException();
-
- if (body.length() > 4096) {
- throw new HttpBadRequestException();
}
body = body.replace("\r", StringUtils.EMPTY);
@@ -129,10 +126,6 @@ public class Post {
throw new HttpNotFoundException();
}
}
-
- if (body.length() > 4096) {
- throw new HttpBadRequestException();
- }
body = body.replace("\r", StringUtils.EMPTY);
if ((msg.ReadOnly && msg.getUser().getUid() != vuid) || userService.isInBLAny(msg.getUser().getUid(), vuid)