You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2021/06/11 12:42:30 UTC
[groovy] branch groovy10132 created (now c289185)
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a change to branch groovy10132
in repository https://gitbox.apache.org/repos/asf/groovy.git.
at c289185 GROOVY-10132: XmlUtil.serialize() Emoji bug
This branch includes the following new commits:
new c289185 GROOVY-10132: XmlUtil.serialize() Emoji bug
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[groovy] 01/01: GROOVY-10132: XmlUtil.serialize() Emoji bug
Posted by pa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch groovy10132
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit c28918529097efed011b978db4a13b1b9a5c7309
Author: Paul King <pa...@asert.com.au>
AuthorDate: Fri Jun 11 22:42:19 2021 +1000
GROOVY-10132: XmlUtil.serialize() Emoji bug
---
.../groovy/xml/streamingmarkupsupport/StreamingMarkupWriter.java | 5 +++--
.../groovy-xml/src/test/groovy/groovy/xml/XmlUtilTest.groovy | 9 +++++++++
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/subprojects/groovy-xml/src/main/java/groovy/xml/streamingmarkupsupport/StreamingMarkupWriter.java b/subprojects/groovy-xml/src/main/java/groovy/xml/streamingmarkupsupport/StreamingMarkupWriter.java
index a9ce038..a67e432 100644
--- a/subprojects/groovy-xml/src/main/java/groovy/xml/streamingmarkupsupport/StreamingMarkupWriter.java
+++ b/subprojects/groovy-xml/src/main/java/groovy/xml/streamingmarkupsupport/StreamingMarkupWriter.java
@@ -175,8 +175,9 @@ public class StreamingMarkupWriter extends Writer {
// High surrogate
this.surrogatePair.append((char) c);
this.haveHighSurrogate = true;
-
- } else if (!this.encoder.canEncode((char) c)) {
+ return;
+ }
+ if (!this.encoder.canEncode((char) c)) {
this.writer.write("&#x");
this.writer.write(Integer.toHexString(c));
this.writer.write(';');
diff --git a/subprojects/groovy-xml/src/test/groovy/groovy/xml/XmlUtilTest.groovy b/subprojects/groovy-xml/src/test/groovy/groovy/xml/XmlUtilTest.groovy
index 02f0df1..e71076b 100644
--- a/subprojects/groovy-xml/src/test/groovy/groovy/xml/XmlUtilTest.groovy
+++ b/subprojects/groovy-xml/src/test/groovy/groovy/xml/XmlUtilTest.groovy
@@ -45,6 +45,15 @@ class XmlUtilTest extends GroovyTestCase {
assertXmlEquals(xml, XmlUtil.serialize(new XmlSlurper().parse(source)))
}
+ def xml2 = '<?xml version="1.0" encoding="UTF-8"?><Name>🎁4</Name>'
+
+ // GROOVY-10132
+ void testSerializeOfSurrogate() {
+ def source = new InputSource(new StringReader(xml2))
+ source.encoding = "UTF-8"
+ assertXmlEquals(xml2, XmlUtil.serialize(new XmlSlurper().parse(source)))
+ }
+
// GROOVY-5361
void testSchemaValidationUtilityMethod() {
Locale dl = Locale.getDefault()