Skip to content

Commit 5db1fcc

Browse files
committed
Patch surrogate handling for attributes (based on apache/xalan-j#4 (comment) fix) and for text
1 parent 25b9c33 commit 5db1fcc

2 files changed

Lines changed: 24 additions & 15 deletions

File tree

src/org/apache/xml/serializer/ToHTMLStream.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,22 +1455,23 @@ else if ((ch < m_maxCharacter) && (m_maxCharacter == 0xFFFF)
14551455
{
14561456
writer.write(ch); // no escaping in this case
14571457
}
1458-
else
14591458
*/
1460-
String outputStringForChar = m_charInfo.getOutputStringForChar(ch);
1461-
if (null != outputStringForChar)
1462-
{
1463-
writer.write(outputStringForChar);
1464-
}
1465-
else if (escapingNotNeeded(ch))
1466-
{
1467-
writer.write(ch); // no escaping in this case
1468-
}
1469-
else
1470-
{
1471-
writer.write("&#");
1472-
writer.write(Integer.toString(ch));
1473-
writer.write(';');
1459+
else {
1460+
String outputStringForChar = m_charInfo.getOutputStringForChar(ch);
1461+
if (null != outputStringForChar)
1462+
{
1463+
writer.write(outputStringForChar);
1464+
}
1465+
else if (escapingNotNeeded(ch))
1466+
{
1467+
writer.write(ch); // no escaping in this case
1468+
}
1469+
else
1470+
{
1471+
writer.write("&#");
1472+
writer.write(Integer.toString(ch));
1473+
writer.write(';');
1474+
}
14741475
}
14751476
}
14761477
cleanStart = i + 1;

src/org/apache/xml/serializer/ToStream.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,6 +1600,14 @@ else if (m_encodingInfo.isInEncoding(ch)) {
16001600
// just leave it get added on to the clean characters
16011601

16021602
}
1603+
else if (Encodings.isHighUTF16Surrogate(ch)) {
1604+
writeOutCleanChars(chars, i, lastDirtyCharProcessed);
1605+
writeUTF16Surrogate(ch, chars, i, end);
1606+
// two input characters processed
1607+
// this increments by one and the for()
1608+
// loop i elf increments by another one.
1609+
lastDirtyCharProcessed = ++i;
1610+
}
16031611
else {
16041612
// This is a fallback plan, we should never get here
16051613
// but if the character wasn't previously handled

0 commit comments

Comments
 (0)