tmiller     02/03/18 10:44:28

  Modified:    java/src/org/apache/xalan/xsltc/runtime TextOutput.java
  Log:
  bug 6935, fixed char escaping in non-URL HTML
  attribute case; also added recognition for URL escaping in HTML4 cite attrs.
  
  Revision  Changes    Path
  1.50      +31 -4     
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/TextOutput.java
  
  Index: TextOutput.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/TextOutput.java,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- TextOutput.java   7 Feb 2002 16:29:28 -0000       1.49
  +++ TextOutput.java   18 Mar 2002 18:44:28 -0000      1.50
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: TextOutput.java,v 1.49 2002/02/07 16:29:28 tmiller Exp $
  + * @(#)$Id: TextOutput.java,v 1.50 2002/03/18 18:44:28 tmiller Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -126,6 +126,7 @@
   
       private static final String EMPTYSTRING     = "";
       private static final String HREF_STR        = "href";
  +    private static final String CITE_STR        = "cite";
       private static final String SRC_STR         = "str";
       private static final String CHAR_ESC_START  = "&#";
       private static final String CDATA_ESC_START = "]]>&#";
  @@ -828,15 +829,41 @@
   
            // URL-encode href attributes in HTML output
            final String tmp = name.toLowerCase();
  -         if  (tmp.equals(HREF_STR) || tmp.equals(SRC_STR)) {
  -             _attributes.add(name,quickAndDirtyUrlEncode(escapeAttr(value)));
  +         if (tmp.equals(HREF_STR) || tmp.equals(SRC_STR) ||
  +              tmp.equals(CITE_STR)) {
  +             _attributes.add(name,
  +                 quickAndDirtyUrlEncode(escapeAttr(value)));
            }
            else {
  -             _attributes.add(expandAttribute(name), escapeAttr(value));
  +             _attributes.add(expandAttribute(name), 
  +                     escapeNonURLAttr(value));
            }
            return;
        }
       }
  +
  +    /**
  +     * Escape non ASCII characters (> u007F) as &#XXX; entities.
  +     */
  +    private String escapeNonURLAttr(String base) {
  +     final int len = base.length() - 1;
  +
  +     char[] ch = base.toCharArray();
  +     StringBuffer buf = new StringBuffer();
  +        for(int i=0; i<base.length(); i++){
  +         if (ch[i] > '\u007F') {
  +             buf.append(CHAR_ESC_START);
  +             buf.append(Integer.toString((int)ch[i]));
  +             buf.append(';');
  +         }
  +         else {
  +             buf.append(ch[i]); 
  +         } 
  +     }
  +     base = buf.toString();
  +     return base;
  +    }
  +
   
       /**
        * End an element or CDATA section in the output document
  
  
  

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

Reply via email to