From baa7b50263ba77458ac5eef4235372711690a393 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Tue, 21 May 2024 13:45:09 -0500 Subject: [PATCH] Fix for namespaced attributes Since we only store them by prefix right now (boo!) at least keep the prefix definition as well. (cherry picked from commit a770c7d60ab14d03d5569df4fa56d2cfb1e4661f) --- src/main/java/eu/siacs/conversations/xml/XmlReader.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/eu/siacs/conversations/xml/XmlReader.java b/src/main/java/eu/siacs/conversations/xml/XmlReader.java index aee7d7819a..5fdf9cfa2b 100644 --- a/src/main/java/eu/siacs/conversations/xml/XmlReader.java +++ b/src/main/java/eu/siacs/conversations/xml/XmlReader.java @@ -73,6 +73,12 @@ public class XmlReader implements Closeable { } tag.setAttribute(name,parser.getAttributeValue(i)); } + int nsStart = parser.getNamespaceCount(parser.getDepth()-1); + int nsEnd = parser.getNamespaceCount(parser.getDepth()); + for (int i = nsStart; i < nsEnd; i++) { + final var prefix = parser.getNamespacePrefix(i); + tag.setAttribute("xmlns" + (prefix == null ? "" : ":" + prefix), parser.getNamespaceUri(i)); + } if (xmlns != null) { tag.setAttribute("xmlns", xmlns); }