Message:

   The following issue has been closed.

   Resolver: Emmanuel Venisse
       Date: Fri, 4 Jul 2003 11:46 AM

Applied today
---------------------------------------------------------------------
View the issue:

  http://jira.codehaus.org/secure/ViewIssue.jspa?key=MAVEN-425


Here is an overview of the issue:
---------------------------------------------------------------------
        Key: MAVEN-425
    Summary: maven-changelog-plugin: need to escape filename
       Type: Improvement

     Status: Closed
   Priority: Minor
 Resolution: FIXED

 Time Spent: Unknown
  Remaining: 0 minutes

    Project: maven
   Versions:
             1.0-beta-9

   Assignee: 
   Reporter: Bruce Chenoweth

    Created: Tue, 13 May 2003 9:55 AM
    Updated: Fri, 4 Jul 2003 11:46 AM
Environment: Windows

Description:
Despite many common-sense reasons not to do so, some users have used the ampersand 
characters in workfile names.

The following code snippet seems to resolve this:

>cvs diff ChangeLogEntry.java
Index: ChangeLogEntry.java
===================================================================
RCS file: /home/cvspublic/maven/src/plugins-build/changelog/src/main/org/apache/
maven/changelog/ChangeLogEntry.java,v
retrieving revision 1.1.1.1
diff -r1.1.1.1 ChangeLogEntry.java
74a75,85
>     /** 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;";
>
179c190
<                 .append(file.getName())
---
>                 .append(escapeValue(file.getName()))
281a293,335
>
>     /**
>      * <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();
>     }


---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


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

Reply via email to