evenisse    2003/07/04 09:24:46

  Modified:    src/plugins-build/changelog/src/main/org/apache/maven/changelog
                        ChangeLogEntry.java
               src/plugins-build/changelog/xdocs changes.xml
  Log:
  Fixed MAVEN-425. Escape filename.
  
  Revision  Changes    Path
  1.2       +70 -3     
maven/src/plugins-build/changelog/src/main/org/apache/maven/changelog/ChangeLogEntry.java
  
  Index: ChangeLogEntry.java
  ===================================================================
  RCS file: 
/home/cvs/maven/src/plugins-build/changelog/src/main/org/apache/maven/changelog/ChangeLogEntry.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ChangeLogEntry.java       24 Jan 2003 03:44:51 -0000      1.1
  +++ ChangeLogEntry.java       4 Jul 2003 16:24:46 -0000       1.2
  @@ -73,6 +73,31 @@
   public class ChangeLogEntry
   {
       /**
  +     * Escaped <code>&lt;</code> entity
  +     */
  +    public static final String LESS_THAN_ENTITY = "&lt;";
  +    
  +    /**
  +     * Escaped <code>&gt;</code> entity
  +     */
  +    public static final String GREATER_THAN_ENTITY = "&gt;";
  +    
  +    /**
  +     * Escaped <code>&amp;</code> entity
  +     */
  +    public static final String AMPERSAND_ENTITY = "&amp;";
  +    
  +    /**
  +     * Escaped <code>'</code> entity
  +     */
  +    public static final String APOSTROPHE_ENTITY = "&apos;";
  +    
  +    /**
  +     * Escaped <code>"</code> entity
  +     */
  +    public static final String QUOTE_ENTITY = "&quot;";
  +    
  +    /**
        * Formatter used by the getDateFormatted method.
        */
       private static final SimpleDateFormat DATE_FORMAT = 
  @@ -176,7 +201,7 @@
               ChangeLogFile file = (ChangeLogFile) e.nextElement();
               buffer.append("\t\t<file>\n")
                   .append("\t\t\t<name>")
  -                .append(file.getName())
  +                .append(escapeValue(file.getName()))
                   .append("</name>\n")
                   .append("\t\t\t<revision>")
                   .append(file.getRevision())
  @@ -278,5 +303,47 @@
       {
           return TIME_FORMAT.format(getDate());
       }
  -
  +    
  +    /** 
  +     * <p>Escape the <code>toString</code> of the given object. 
  +     * For use in an attribute value.</p> 
  +     * 
  +     * swiped from jakarta-commons/betwixt -- XMLUtils.java 
  +     * 
  +     * @param value escape <code>value.toString()</code> 
  +     * @return text with characters restricted (for use in attributes) escaped 
  +     */ 
  +    public static final String escapeValue(Object value) { 
  +        StringBuffer buffer = new StringBuffer(value.toString()); 
  +        for (int i=0, size = buffer.length(); i <size; i++) { 
  +            switch (buffer.charAt(i)) { 
  +                case '<': 
  +                    buffer.replace(i, i+1, LESS_THAN_ENTITY); 
  +                    size += 3; 
  +                    i+=3; 
  +                    break; 
  +                case '>': 
  +                    buffer.replace(i, i+1, GREATER_THAN_ENTITY); 
  +                    size += 3; 
  +                    i += 3; 
  +                    break; 
  +                case '&': 
  +                    buffer.replace(i, i+1, AMPERSAND_ENTITY); 
  +                    size += 4; 
  +                    i += 4; 
  +                    break; 
  +                case '\'': 
  +                    buffer.replace(i, i+1, APOSTROPHE_ENTITY); 
  +                    size += 4; 
  +                    i += 4; 
  +                    break; 
  +                case '\"': 
  +                    buffer.replace(i, i+1, QUOTE_ENTITY); 
  +                    size += 5; 
  +                    i += 5; 
  +                    break; 
  +            } 
  +        } 
  +        return buffer.toString(); 
  +    }
   }
  
  
  
  1.5       +3 -0      maven/src/plugins-build/changelog/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/maven/src/plugins-build/changelog/xdocs/changes.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- changes.xml       2 Jul 2003 09:04:16 -0000       1.4
  +++ changes.xml       4 Jul 2003 16:24:46 -0000       1.5
  @@ -8,6 +8,9 @@
   
     <body>
       <release version="1.3" date="in CVS">
  +      <action dev="evenisse" type="fix" due-to="Bruce Chenoweth">
  +        Fixed MAVEN-425. Escape filename.
  +      </action>
         <action dev="evenisse" type="fix">
           fixed MAVEN-493. I register reports only if source, test,... exists.
           So, corresponding entrys in menu will appear only if reports are registered.
  
  
  

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

Reply via email to