sboag       00/06/21 21:42:25

  Modified:    src/org/apache/xalan/xpath/xml FormatterToHTML.java
  Log:
  Made a SpecialEscapeURLs property on FormatterToHTML, and set it to false by 
default, so that href attributes are no longer escaped with %xx, but should use 
normal attribute escaping.  In the case where this property is set to true, 
double-quotes will now be escaped with the XML escaping mechanism.
  
  Revision  Changes    Path
  1.33      +31 -3     
xml-xalan/src/org/apache/xalan/xpath/xml/FormatterToHTML.java
  
  Index: FormatterToHTML.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/src/org/apache/xalan/xpath/xml/FormatterToHTML.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- FormatterToHTML.java      2000/05/17 22:40:59     1.32
  +++ FormatterToHTML.java      2000/06/22 04:42:24     1.33
  @@ -311,6 +311,24 @@
      */
     static private ElemDesc m_dummy = new ElemDesc(0|ElemDesc.BLOCK);
     
  +  private boolean m_specialEscapeURLs = false;
  +  
  +  /**
  +   * Tells if the formatter should use special URL escaping.
  +   */
  +  public void setSpecialEscapeURLs(boolean bool)
  +  {
  +    m_specialEscapeURLs = bool;
  +  }
  +  
  +  /**
  +   * Tells if the formatter should use special URL escaping.
  +   */
  +  public boolean getSpecialEscapeURLs()
  +  {
  +    return m_specialEscapeURLs;
  +  }
  +  
     /**
      * Get a description of the given element.
      */
  @@ -617,7 +635,8 @@
         this.accum(name);
         this.accum('=');
         this.accum('\"');
  -      if(elemDesc.isAttrFlagSet(nameUpper, ElemDesc.ATTRURL))
  +      if(m_specialEscapeURLs &&
  +         elemDesc.isAttrFlagSet(nameUpper, ElemDesc.ATTRURL))
           writeAttrURI(value, this.m_encoding);
         else
           writeAttrString(value, this.m_encoding);
  @@ -647,7 +666,7 @@
       {
         char ch = stringArray[i];
         // if first 8 bytes are 0, no need to append them.
  -      if ((ch < 9) || (ch > 127) || (ch == '"') || (ch == ' '))
  +      if ((ch < 9) || (ch > 127) || /*(ch == '"') || -sb, as per #PDIK4L9LZY 
*/ (ch == ' '))
         {       
           int b1 = (int)((((int)ch) & MASK1) >> 8);
           int b2 = (int)(((int)ch) & MASK2);
  @@ -658,7 +677,16 @@
           }
           accum("%");
           accum(Integer.toHexString(b2));              
  -      }      
  +      }
  +      else if(ch == '"')
  +      {
  +        accum('&');
  +        accum('q');
  +        accum('u');
  +        accum('o');
  +        accum('t');
  +        accum(';');
  +      }
         else
         {
           accum(ch);
  
  
  

Reply via email to