From c1f3f8ce13ab24986257342b33b5ae0c073d8d25 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 18 Nov 2020 20:04:55 +0100 Subject: [PATCH 1/4] Smack 4.4.0-rc2 --- version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version b/version index 0bc786cbf..85eec5e3b 100644 --- a/version +++ b/version @@ -1 +1 @@ -4.4.0-rc2-SNAPSHOT +4.4.0-rc2 From 821bdf6d86437b1e4a87c58d737dcf1d32c04ab6 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 18 Nov 2020 21:19:01 +0100 Subject: [PATCH 2/4] Smack 4.4.0-rc3-SNAPSHOT --- version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version b/version index 85eec5e3b..1a50af830 100644 --- a/version +++ b/version @@ -1 +1 @@ -4.4.0-rc2 +4.4.0-rc3-SNAPSHOT From ca497a2199ae79bcf398372e661af5bcccdab219 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 25 Nov 2020 20:49:31 +0100 Subject: [PATCH 3/4] [core] Fix parseContentDepthWithRoundtrip() and add tests --- .../smack/util/PacketParserUtils.java | 5 ++- .../smack/util/PacketParserUtilsTest.java | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java b/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java index 67249b559..3501d8a2a 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java @@ -377,10 +377,9 @@ public class PacketParserUtils { outerloop: while (true) { switch (event) { case START_ELEMENT: - if (startElementJustSeen) { - sb.rightAngleBracket(); - } startElementJustSeen = true; + String openElementTag = parser.getText(); + sb.append(openElementTag); break; case END_ELEMENT: boolean isEmptyElement = false; diff --git a/smack-core/src/test/java/org/jivesoftware/smack/util/PacketParserUtilsTest.java b/smack-core/src/test/java/org/jivesoftware/smack/util/PacketParserUtilsTest.java index 3ac5215d5..f8eacf5cd 100644 --- a/smack-core/src/test/java/org/jivesoftware/smack/util/PacketParserUtilsTest.java +++ b/smack-core/src/test/java/org/jivesoftware/smack/util/PacketParserUtilsTest.java @@ -854,4 +854,40 @@ public class PacketParserUtilsTest { StanzaError error = PacketParserUtils.parseError(parser); assertEquals(text, error.getDescriptiveText()); } + + @ParameterizedTest + @EnumSource(SmackTestUtil.XmlPullParserKind.class) + public void testParseElementSimple(SmackTestUtil.XmlPullParserKind parserKind) throws TransformerException, ParserConfigurationException, FactoryConfigurationError, XmlPullParserException, IOException { + String unknownElement = XMLBuilder.create("unknown-element") + .ns("https://example.org/non-existent") + .e("inner") + .t("test") + .asString(outputProperties); + + XmlPullParser xmlPullParser = SmackTestUtil.getParserFor(unknownElement, parserKind); + + CharSequence unknownElementParsed = PacketParserUtils.parseElement(xmlPullParser); + assertXmlSimilar(unknownElement, unknownElementParsed); + } + + @ParameterizedTest + @EnumSource(SmackTestUtil.XmlPullParserKind.class) + public void testParseElementExtended(SmackTestUtil.XmlPullParserKind parserKind) throws TransformerException, ParserConfigurationException, FactoryConfigurationError, XmlPullParserException, IOException { + String unknownElement = XMLBuilder.create("unknown-element") + .ns("https://example.org/non-existent") + .a("attribute-outer", "foo") + .e("inner") + .a("attribute-inner", "bar") + .a("attribute-inner-2", "baz") + .t("test") + .up() + .e("empty-element") + .up() + .asString(outputProperties); + + XmlPullParser xmlPullParser = SmackTestUtil.getParserFor(unknownElement, parserKind); + + CharSequence unknownElementParsed = PacketParserUtils.parseElement(xmlPullParser); + assertXmlSimilar(unknownElement, unknownElementParsed); + } } From 02c9058c3d0fc1a49cb6313b1bed9ab92332ea90 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 25 Nov 2020 20:50:58 +0100 Subject: [PATCH 4/4] [core] Remove @SuppressWarnings for parseContentDepthWithRoundtrip() Also use the most specific return type in the method's signature. --- .../java/org/jivesoftware/smack/util/PacketParserUtils.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java b/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java index 3501d8a2a..d5168ba50 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java @@ -299,7 +299,7 @@ public class PacketParserUtils { */ public static CharSequence parseContentDepth(XmlPullParser parser, int depth, boolean fullNamespaces) throws XmlPullParserException, IOException { if (parser.supportsRoundtrip()) { - return parseContentDepthWithRoundtrip(parser, depth, fullNamespaces); + return parseContentDepthWithRoundtrip(parser, depth); } else { return parseContentDepthWithoutRoundtrip(parser, depth, fullNamespaces); } @@ -368,8 +368,7 @@ public class PacketParserUtils { return xml; } - @SuppressWarnings("UnusedVariable") - private static CharSequence parseContentDepthWithRoundtrip(XmlPullParser parser, int depth, boolean fullNamespaces) + private static XmlStringBuilder parseContentDepthWithRoundtrip(XmlPullParser parser, int depth) throws XmlPullParserException, IOException { XmlStringBuilder sb = new XmlStringBuilder(); XmlPullParser.Event event = parser.getEventType();