Maven 1.x Changelog Plugin
  1. Maven 1.x Changelog Plugin
  2. MPCHANGELOG-8

maven-changelog-plugin: need to escape filename

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2
    • Fix Version/s: 1.3
    • Labels:
      None
    • Environment:
      Windows
    • Number of attachments :
      1

      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><</code> entity */
      > public static final String LESS_THAN_ENTITY = "<";
      > /** Escaped <code>></code> entity */
      > public static final String GREATER_THAN_ENTITY = ">";
      > /** Escaped <code>&</code> entity */
      > public static final String AMPERSAND_ENTITY = "&";
      > /** Escaped <code>'</code> entity */
      > public static final String APOSTROPHE_ENTITY = "'";
      > /** Escaped <code>"</code> entity */
      > public static final String QUOTE_ENTITY = """;
      >
      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)

      { > 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();
      > }

        Activity

        Hide
        Emmanuel Venisse added a comment -

        Applied today

        Show
        Emmanuel Venisse added a comment - Applied today

          People

          • Assignee:
            Unassigned
            Reporter:
            Bruce Chenoweth
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: