santiagopg    2002/07/22 13:11:32

  Modified:    java/src/org/apache/xalan/xsltc/runtime/output
                        StreamHTMLOutput.java StreamOutput.java
                        StreamXMLOutput.java
  Log:
  Fix for Bugzilla 10715.
  
  Revision  Changes    Path
  1.15      +55 -1     
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/output/StreamHTMLOutput.java
  
  Index: StreamHTMLOutput.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/output/StreamHTMLOutput.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- StreamHTMLOutput.java     24 Jun 2002 20:09:43 -0000      1.14
  +++ StreamHTMLOutput.java     22 Jul 2002 20:11:32 -0000      1.15
  @@ -416,4 +416,58 @@
            _headTagOpen = false;
        }
       } 
  +
  +    /**
  +     * This method escapes special characters used in text nodes
  +     */
  +    protected void escapeCharacters(char[] ch, int off, int len) {
  +     int limit = off + len;
  +     int offset = off;
  +
  +     if (limit > ch.length) {
  +         limit = ch.length;
  +     }
  +
  +     // Step through characters and escape all special characters
  +     for (int i = off; i < limit; i++) {
  +         final char current = ch[i];
  +
  +         switch (current) {
  +         case '&':
  +             _buffer.append(ch, offset, i - offset).append(AMP);
  +             offset = i + 1;
  +             break;
  +         case '<':
  +             _buffer.append(ch, offset, i - offset).append(LT);
  +             offset = i + 1;
  +             break;
  +         case '>':
  +             _buffer.append(ch, offset, i - offset).append(GT);
  +             offset = i + 1;
  +             break;
  +         case '"':
  +             _buffer.append(ch, offset, i - offset).append(QUOT);
  +             offset = i + 1;
  +             break;
  +         case '\u00A0':
  +             _buffer.append(ch, offset, i - offset).append(NBSP);
  +             offset = i + 1;
  +             break;
  +         default:
  +             if ((current >= '\u007F' && current < '\u00A0') ||
  +                 (_is8859Encoded && current > '\u00FF'))
  +             {
  +                 _buffer.append(ch, offset, i - offset)
  +                        .append(CHAR_ESC_START)
  +                        .append(Integer.toString((int)ch[i]))
  +                        .append(';');
  +                 offset = i + 1;
  +             }
  +         }
  +     }
  +     // Output remaining characters (that do not need escaping).
  +     if (offset < limit) {
  +         _buffer.append(ch, offset, limit - offset);
  +     }
  +    }
   }
  
  
  
  1.18      +7 -50     
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/output/StreamOutput.java
  
  Index: StreamOutput.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/output/StreamOutput.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- StreamOutput.java 26 Jun 2002 22:55:07 -0000      1.17
  +++ StreamOutput.java 22 Jul 2002 20:11:32 -0000      1.18
  @@ -79,7 +79,8 @@
       protected static final String LT       = "&lt;";
       protected static final String GT       = "&gt;";
       protected static final String CRLF     = "&#xA;";
  -    protected static final String QUOTE    = "&quot;";
  +    protected static final String APOS     = "&apos;";
  +    protected static final String QUOT     = "&quot;";
       protected static final String NBSP     = "&nbsp;";
   
       protected static final String CHAR_ESC_START  = "&#";
  @@ -242,55 +243,11 @@
                : MAX_INDENT);
       }
   
  +    /**
  +     * This method escapes special characters used in text nodes. It
  +     * is overriden for XML and HTML output.
  +     */
       protected void escapeCharacters(char[] ch, int off, int len) {
  -     int limit = off + len;
  -     int offset = off;
  -
  -     if (limit > ch.length) {
  -         limit = ch.length;
  -     }
  -
  -     // Step through characters and escape all special characters
  -     for (int i = off; i < limit; i++) {
  -         final char current = ch[i];
  -
  -         switch (current) {
  -         case '&':
  -             _buffer.append(ch, offset, i - offset);
  -             _buffer.append(AMP);
  -             offset = i + 1;
  -             break;
  -         case '<':
  -             _buffer.append(ch, offset, i - offset);
  -             _buffer.append(LT);
  -             offset = i + 1;
  -             break;
  -         case '>':
  -             _buffer.append(ch, offset, i - offset);
  -             _buffer.append(GT);
  -             offset = i + 1;
  -             break;
  -         case '\u00a0':
  -             _buffer.append(ch, offset, i - offset);
  -             _buffer.append(NBSP);
  -             offset = i + 1;
  -             break;
  -         default:
  -             if ((current >= '\u007F' && current < '\u00A0') ||
  -                 (_is8859Encoded && current > '\u00FF'))
  -             {
  -                 _buffer.append(ch, offset, i - offset);
  -                 _buffer.append(CHAR_ESC_START);
  -                 _buffer.append(Integer.toString((int)ch[i]));
  -                 _buffer.append(';');
  -                 offset = i + 1;
  -             }
  -         }
  -     }
  -     // Output remaining characters (that do not need escaping).
  -     if (offset < limit) {
  -         _buffer.append(ch, offset, limit - offset);
  -     }
       }
   
       protected void appendAttributes() {
  
  
  
  1.17      +56 -2     
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/output/StreamXMLOutput.java
  
  Index: StreamXMLOutput.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/output/StreamXMLOutput.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- StreamXMLOutput.java      24 Jun 2002 20:09:43 -0000      1.16
  +++ StreamXMLOutput.java      22 Jul 2002 20:11:32 -0000      1.17
  @@ -389,7 +389,7 @@
                offset = i + 1;
                break;
            case '"':
  -             result.append(ch, offset, i - offset).append(QUOTE);
  +             result.append(ch, offset, i - offset).append(QUOT);
                offset = i + 1;
                break;
            case '<':
  @@ -411,5 +411,59 @@
            result.append(ch, offset, limit - offset);
        }
        return result.toString();
  +    }
  +
  +    /**
  +     * This method escapes special characters used in text nodes
  +     */
  +    protected void escapeCharacters(char[] ch, int off, int len) {
  +     int limit = off + len;
  +     int offset = off;
  +
  +     if (limit > ch.length) {
  +         limit = ch.length;
  +     }
  +
  +     // Step through characters and escape all special characters
  +     for (int i = off; i < limit; i++) {
  +         final char current = ch[i];
  +
  +         switch (current) {
  +         case '&':
  +             _buffer.append(ch, offset, i - offset).append(AMP);
  +             offset = i + 1;
  +             break;
  +         case '<':
  +             _buffer.append(ch, offset, i - offset).append(LT);
  +             offset = i + 1;
  +             break;
  +         case '>':
  +             _buffer.append(ch, offset, i - offset).append(GT);
  +             offset = i + 1;
  +             break;
  +         case '\'':
  +             _buffer.append(ch, offset, i - offset).append(APOS);
  +             offset = i + 1;
  +             break;
  +         case '"':
  +             _buffer.append(ch, offset, i - offset).append(QUOT);
  +             offset = i + 1;
  +             break;
  +         default:
  +             if ((current >= '\u007F' && current < '\u00A0') ||
  +                 (_is8859Encoded && current > '\u00FF'))
  +             {
  +                 _buffer.append(ch, offset, i - offset)
  +                        .append(CHAR_ESC_START)
  +                        .append(Integer.toString((int)ch[i]))
  +                        .append(';');
  +                 offset = i + 1;
  +             }
  +         }
  +     }
  +     // Output remaining characters (that do not need escaping).
  +     if (offset < limit) {
  +         _buffer.append(ch, offset, limit - offset);
  +     }
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to