< prev index next >
src/com/sun/org/apache/xml/internal/serializer/ToHTMLStream.java
Print this page
@@ -1,8 +1,7 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -41,10 +40,11 @@
*
* This class is not a public API, it is public
* because it is used from another package.
*
* @xsl.usage internal
+ * @LastModified: Sept 2018
*/
public final class ToHTMLStream extends ToStream
{
/** This flag is set while receiving events from the DTD */
@@ -1019,11 +1019,11 @@
protected void processAttribute(
java.io.Writer writer,
String name,
String value,
ElemDesc elemDesc)
- throws IOException
+ throws IOException, SAXException
{
writer.write(' ');
if ( ((value.length() == 0) || value.equalsIgnoreCase(name))
&& elemDesc != null
@@ -1343,11 +1343,11 @@
*
* @throws org.xml.sax.SAXException
*/
public void writeAttrString(
final java.io.Writer writer, String string, String encoding)
- throws IOException
+ throws IOException, SAXException
{
final int end = string.length();
if (end > m_attrBuff.length)
{
m_attrBuff = new char[end * 2 + 1];
@@ -1395,17 +1395,20 @@
{
i = pos - 1;
}
else
{
- if (Encodings.isHighUTF16Surrogate(ch))
+ if (Encodings.isHighUTF16Surrogate(ch) ||
+ Encodings.isLowUTF16Surrogate(ch))
{
-
- writeUTF16Surrogate(ch, chars, i, end);
- i++; // two input characters processed
- // this increments by one and the for()
- // loop itself increments by another one.
+ if (writeUTF16Surrogate(ch, chars, i, end) >= 0) {
+ // move the index if the low surrogate is consumed
+ // as writeUTF16Surrogate has written the pair
+ if (Encodings.isHighUTF16Surrogate(ch)) {
+ i++;
+ }
+ }
}
// The next is kind of a hack to keep from escaping in the case
// of Shift_JIS and the like.
< prev index next >