|
41 | 41 |
|
42 | 42 | /*
|
43 | 43 | * @test
|
| 44 | + * @bug 8207760 8349699 |
| 45 | + * @summary Verifies that a surrogate pair at the edge of a buffer is properly handled |
44 | 46 | * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
|
45 | 47 | * @run testng/othervm transform.JDK8207760
|
46 |
| - * @summary Verifies that a surrogate pair at the edge of a buffer is properly handled |
47 |
| - * @bug 8207760 |
48 | 48 | */
|
49 | 49 | public class JDK8207760 {
|
50 | 50 | final String xsl8207760 =
|
@@ -101,6 +101,33 @@ public Object[][] getDataBug8207760_cdata() {
|
101 | 101 | };
|
102 | 102 | }
|
103 | 103 |
|
| 104 | + /* |
| 105 | + * @bug 8349699 |
| 106 | + * Verifies that a surrogate pair at the edge of a buffer is properly handled |
| 107 | + * when serializing into a Character section. |
| 108 | + */ |
| 109 | + @Test |
| 110 | + public final void testBug8349699() throws Exception { |
| 111 | + String xs = "x".repeat(1017); |
| 112 | + String expected = xs + "\uD835\uDF03\uD835\uDF00\uD835\uDF00\uD835\uDF00\uD835\uDF00"; |
| 113 | + String xml = "<?xml version=\"1.0\" ?><a>{1017x}\uD835\uDF03\uD835\uDF00\uD835\uDF00<b>\uD835\uDF00</b>\uD835\uDF00</a> " |
| 114 | + .replace("{1017x}", xs); |
| 115 | + String xsl = """ |
| 116 | + <?xml version="1.0" encoding="UTF-8"?> |
| 117 | + <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
| 118 | + <xsl:output encoding="UTF-8" method="text" /> |
| 119 | + <xsl:template match="/"><xsl:apply-templates select="node()" /></xsl:template> |
| 120 | + </xsl:stylesheet> |
| 121 | + """; |
| 122 | + |
| 123 | + Transformer t = createTransformerFromInputstream( |
| 124 | + new ByteArrayInputStream(xsl.getBytes(StandardCharsets.UTF_8))); |
| 125 | + //t.setOutputProperty(OutputKeys.ENCODING, StandardCharsets.UTF_8.name()); |
| 126 | + StringWriter sw = new StringWriter(); |
| 127 | + t.transform(new StreamSource(new StringReader(xml)), new StreamResult(sw)); |
| 128 | + Assert.assertEquals(sw.toString(), expected); |
| 129 | + } |
| 130 | + |
104 | 131 | /*
|
105 | 132 | * @bug 8207760
|
106 | 133 | * Verifies that a surrogate pair at the edge of a buffer is properly handled
|
|
0 commit comments