From 7db4435e7c2fc065023215a52675bcd5a02dca6b Mon Sep 17 00:00:00 2001 From: kosyak Date: Thu, 1 Feb 2024 20:20:48 +0100 Subject: [PATCH] throw invalid viewType exception --- .../conversations/entities/Conversation.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index 5536911c7..e61cf1dd1 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -2666,6 +2666,10 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl } } + if (viewType == -1) { + throw new RuntimeException("Invalid field " + responseElement.getName() + " " + formType + " " + fieldType + " " + el.getName() + " " + el); + } + return new Field(eu.siacs.conversations.xmpp.forms.Field.parse(el), viewType); } @@ -2689,10 +2693,22 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl return field; } } + + if (viewType == -1) { + throw new RuntimeException("Invalid element " + el.getName() + " " + el.getNamespace() + " " + el); + } } else if (response != null) { viewType = TYPE_ERROR; } + if (viewType == -1) { + if (responseElement == null) { + throw new RuntimeException("Invalid element - nullable response"); + } else { + throw new RuntimeException("Invalid element, type " + response.getType()); + } + } + Item item = new Item(el, viewType); items.put(pos, item); return item;