cziegeler    01/10/01 05:18:08

  Modified:    src/org/apache/cocoon/serialization LinkSerializer.java
  Log:
  Fixed bugs: mailto can not be traversed, links containing ankers are not properly 
handled
  
  Revision  Changes    Path
  1.4       +13 -3     
xml-cocoon2/src/org/apache/cocoon/serialization/LinkSerializer.java
  
  Index: LinkSerializer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/org/apache/cocoon/serialization/LinkSerializer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LinkSerializer.java       2001/08/20 13:55:16     1.3
  +++ LinkSerializer.java       2001/10/01 12:18:07     1.4
  @@ -20,7 +20,7 @@
   
   /**
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.3 $ $Date: 2001/08/20 13:55:16 $
  + * @version CVS $Revision: 1.4 $ $Date: 2001/10/01 12:18:07 $
    */
   
   public class LinkSerializer extends ExtendedXLinkPipe implements Serializer, 
Poolable {
  @@ -44,18 +44,28 @@
   
       public void simpleLink(String href, String role, String arcrole, String title, 
String show, String actuate, String uri, String name, String raw, Attributes attr)
       throws SAXException {
  -        if (traversable(href)) out.println(href);
  +        if (traversable(href)) this.print(href);
       }
   
       public void startLocator(String href, String role, String title, String label, 
String uri, String name, String raw, Attributes attr)
       throws SAXException {
  -        if (traversable(href)) out.println(href);
  +        if (traversable(href)) this.print(href);
       }
   
       private boolean traversable(String href) {
           if (href.charAt(0) == '#') return false;
           if (href.indexOf("://") != -1) return false;
  +        if (href.startsWith("mailto:";) == true) return false;
           return true;
  +    }
  +
  +    private void print(String href) {
  +        int ankerPos = href.indexOf('#');
  +        if (ankerPos == -1) {
  +            out.println(href);
  +        } else {
  +            out.println(href.substring(0, ankerPos));
  +        }
       }
   
       /**
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to