jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Maven 1.x Changelog Plugin
  • MPCHANGELOG-8

maven-changelog-plugin: need to escape filename

  • Log In
  • Views
    • XML
    • Word
    • Printable

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

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

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Java Source File
    ChangeLogEntry.java
    13/May/03 9:56 AM
    11 kB
    Bruce Chenoweth

Activity

  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Emmanuel Venisse added a comment - 04/Jul/03 11:46 AM

Applied today

Show
Emmanuel Venisse added a comment - 04/Jul/03 11:46 AM Applied today

People

  • Assignee:
    Unassigned
    Reporter:
    Bruce Chenoweth
Vote (1)
Watch (0)

Dates

  • Created:
    13/May/03 9:55 AM
    Updated:
    15/Nov/03 10:36 AM
    Resolved:
    04/Jul/03 11:46 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.