From 084fbad0cb9d3978a17d1085adb51f611d1e5be1 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Thu, 18 Jan 2024 10:42:30 +0100 Subject: [PATCH] [jid] Add test for leading and trailing whitespace in input --- .../src/test/java/org/jxmpp/jid/impl/JidCreateTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/jxmpp-jid/src/test/java/org/jxmpp/jid/impl/JidCreateTest.java b/jxmpp-jid/src/test/java/org/jxmpp/jid/impl/JidCreateTest.java index cbc90f7..3bfdfad 100644 --- a/jxmpp-jid/src/test/java/org/jxmpp/jid/impl/JidCreateTest.java +++ b/jxmpp-jid/src/test/java/org/jxmpp/jid/impl/JidCreateTest.java @@ -181,4 +181,13 @@ public void noCachedJidShadowingLocalpartTest() throws XmppStringprepException { String invalidJid = "@noCachedJidShadowingLocalpartTest.org"; assertThrows(XmppStringprepException.class, () -> JidCreate.from(invalidJid) ); } + + @Test + public void leadingAndTrailingWhitespaceTest() throws XmppStringprepException { + String invalidJid = " foo@leadingAndTrailingWhitespaceTest.org "; + assertThrows(XmppStringprepException.class, () -> JidCreate.from(invalidJid) ); + + String invalidJid2 = " foo@leadingAndTrailingWhitespaceTest.org/bar "; + assertThrows(XmppStringprepException.class, () -> JidCreate.from(invalidJid2) ); + } }