This is an automated email from the ASF dual-hosted git repository.
chibenwa pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-jsieve.git
The following commit(s) were added to refs/heads/master by this push:
new 257a731 [FIX] XmlOut: test the emptiness of a prefix or uri on its
content (#38)
257a731 is described below
commit 257a73154897325a94bad25550e7e7d17620050d
Author: Benoit TELLIER <[email protected]>
AuthorDate: Thu Nov 12 15:11:07 2026 +0100
[FIX] XmlOut: test the emptiness of a prefix or uri on its content (#38)
"".equals(...) is false for an empty CharSequence that is not a String,
which qualified the name as ":localName".
Fixes https://github.com/linagora/james-jsieve/issues/49
---
util/src/main/java/org/apache/jsieve/util/XmlOut.java | 2 +-
util/src/test/java/org/apache/jsieve/util/XmlOutTest.java | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/util/src/main/java/org/apache/jsieve/util/XmlOut.java
b/util/src/main/java/org/apache/jsieve/util/XmlOut.java
index 1059769..daf2d5a 100644
--- a/util/src/main/java/org/apache/jsieve/util/XmlOut.java
+++ b/util/src/main/java/org/apache/jsieve/util/XmlOut.java
@@ -654,7 +654,7 @@ public final class XmlOut implements SieveToXml.Out {
private CharSequence toName(CharSequence localName, CharSequence uri,
CharSequence prefix) {
final CharSequence name;
- if (prefix == null || "".equals(prefix) || uri == null ||
"".equals(uri)) {
+ if (prefix == null || prefix.length() == 0 || uri == null ||
uri.length() == 0) {
name = localName;
} else {
name = prefix + ":" + localName;
diff --git a/util/src/test/java/org/apache/jsieve/util/XmlOutTest.java
b/util/src/test/java/org/apache/jsieve/util/XmlOutTest.java
index 1c485e6..fd97e40 100644
--- a/util/src/test/java/org/apache/jsieve/util/XmlOutTest.java
+++ b/util/src/test/java/org/apache/jsieve/util/XmlOutTest.java
@@ -65,4 +65,15 @@ public class XmlOutTest {
assertThat(write("\uD83Dx", "").getAttribute("a")).isEqualTo("?x");
}
+ @Test
+ public void anEmptyNonStringPrefixShouldNotQualifyTheName() throws
Exception {
+ StringWriter writer = new StringWriter();
+ XmlOut out = new XmlOut(writer);
+ out.openElement("e");
+ out.attribute("a", "urn:x", new StringBuilder(), "v");
+ out.closeElement();
+
+ assertThat(writer.toString()).contains(" a=").doesNotContain(":a=");
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]