You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2001/10/01 14:17:47 UTC

cvs commit: xml-cocoon2/src/org/apache/cocoon/serialization LinkSerializer.java

cziegeler    01/10/01 05:17:47

  Modified:    src/org/apache/cocoon/serialization Tag: cocoon_20_branch
                        LinkSerializer.java
  Log:
  Fixed bugs: mailto can not be traversed, links containing ankers are not properly handled
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.1.1.2.3 +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.1.1.1.2.2
  retrieving revision 1.1.1.1.2.3
  diff -u -r1.1.1.1.2.2 -r1.1.1.1.2.3
  --- LinkSerializer.java	2001/08/20 14:07:33	1.1.1.1.2.2
  +++ LinkSerializer.java	2001/10/01 12:17:47	1.1.1.1.2.3
  @@ -20,7 +20,7 @@
   
   /**
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1.1.1.2.2 $ $Date: 2001/08/20 14:07:33 $
  + * @version CVS $Revision: 1.1.1.1.2.3 $ $Date: 2001/10/01 12:17:47 $
    */
   
   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:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org