You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@gump.apache.org by bo...@apache.org on 2003/05/23 10:16:19 UTC

cvs commit: jakarta-gump/java Jenny.java

bodewig     2003/05/23 01:16:19

  Modified:    java     Jenny.java
  Log:
  After being bitten by the ampersand in ldap-common's URL: escape more
  characters when creating the cache-filename.
  
  Revision  Changes    Path
  1.24      +32 -7     jakarta-gump/java/Jenny.java
  
  Index: Jenny.java
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/java/Jenny.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- Jenny.java	16 Feb 2003 13:25:55 -0000	1.23
  +++ Jenny.java	23 May 2003 08:16:19 -0000	1.24
  @@ -439,9 +439,34 @@
        */
       private String getCachedNodeName(Element node) {
           String hrefAttribute = node.getAttribute("href");
  -        return "cache/" 
  -            + hrefAttribute.replace('/', '_').replace(':', '_')
  -                           .replace('*', '_').replace('~', '_')
  -            + ".xml";
  +        StringBuffer sb = new StringBuffer("cache/");
  +        int len = hrefAttribute.length();
  +        for (int i = 0; i < len; i++) {
  +            char c = hrefAttribute.charAt(i);
  +            switch (c) {
  +            case '/':
  +            case ':':
  +            case '*':
  +            case '~':
  +            case '?':
  +            case '&':
  +            case '\\':
  +            case ';':
  +            case '(':
  +            case ')':
  +            case ' ':
  +            case '=':
  +                // these may cause trouble in file names or on the
  +                // command line
  +                sb.append('_');
  +                break;
  +                
  +            default:
  +                sb.append(c);
  +                break;
  +            }
  +        }
  +        
  +        return sb.toString() + ".xml";
       }
   }