From a6112d0cc907b13c01dad86cd49569540ce80626 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 15 Feb 2018 11:37:08 +0300 Subject: server: validate ws message --- juick-server/src/main/java/com/juick/server/WebsocketManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'juick-server') diff --git a/juick-server/src/main/java/com/juick/server/WebsocketManager.java b/juick-server/src/main/java/com/juick/server/WebsocketManager.java index a260817d..0fa3c84c 100644 --- a/juick-server/src/main/java/com/juick/server/WebsocketManager.java +++ b/juick-server/src/main/java/com/juick/server/WebsocketManager.java @@ -147,7 +147,9 @@ public class WebsocketManager extends TextWebSocketHandler { if (c.visitor.getName().equals(serviceUser)) { try { Message draft = jsonMapper.readValue(message.asBytes(), Message.class); - serverManager.processMessage(draft.getUser(), draft.getText(), draft.getAttachment().getUrl()); + if (draft.getUser() != null && (draft.getText() != null || draft.getAttachment() != null)) { + serverManager.processMessage(draft.getUser(), draft.getText(), draft.getAttachment().getUrl()); + } } catch (IOException e) { throw new HttpBadRequestException(); } -- cgit v1.2.3