morten      01/09/12 03:48:31

  Modified:    java/src/org/apache/xalan/xsltc/runtime TextOutput.java
  Log:
  Updated the output handler to URL encode href attributes in HTML output.
  I used the URLEncoder class in java.net
  PR:           bugzilla 1512
  Obtained from:        n/a
  Submitted by: [EMAIL PROTECTED]
  Reviewed by:  [EMAIL PROTECTED]
  
  Revision  Changes    Path
  1.26      +11 -3     
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.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- TextOutput.java   2001/09/12 08:35:11     1.25
  +++ TextOutput.java   2001/09/12 10:48:30     1.26
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: TextOutput.java,v 1.25 2001/09/12 08:35:11 morten Exp $
  + * @(#)$Id: TextOutput.java,v 1.26 2001/09/12 10:48:30 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -66,6 +66,7 @@
   package org.apache.xalan.xsltc.runtime;
   
   import java.io.*;
  +import java.net.URLEncoder;
   import java.util.Stack;
   import java.util.Enumeration;
   
  @@ -589,6 +590,13 @@
        if (_outputType == TEXT) return; 
   
        if (_startTagOpen) {
  +
  +         // URL-encode href attributes in HTML output
  +         if ((_outputType == HTML) && (name.equals("href"))) {
  +             _attributes.add(name, URLEncoder.encode(value));
  +             return;
  +         }
  +
            // Intercept namespace declarations and handle them separately
            if (name.startsWith("xmlns")) {
                if (name.length() == 5)
  @@ -610,9 +618,9 @@
                    if (uri.equals(EMPTYSTRING)) name = localname;
                }
                if (_outputType == HTML)
  -                 _attributes.add(name,value);
  +                 _attributes.add(name, value);
                else
  -                 _attributes.add(name,escapeChars(value));
  +                 _attributes.add(name, escapeChars(value));
            }
        }
        else {
  
  
  

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

Reply via email to