Fixed MAVEN-425. Escape filename.

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@113600 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
evenisse
2003-07-04 16:24:46 +00:00
parent d17a9f34be
commit f6b478f1b4
2 changed files with 73 additions and 3 deletions

View File

@@ -68,10 +68,35 @@ import java.util.Vector;
* @task add time of change to the entry
* @task investigate betwixt for toXML method
* @author <a href="mailto:dion@multitask.com.au">dIon Gillard</a>
* @version $Id: ChangeLogEntry.java,v 1.1 2003/01/24 03:44:51 jvanzyl Exp $
* @version $Id: ChangeLogEntry.java,v 1.2 2003/07/04 16:24:46 evenisse Exp $
*/
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.
*/
@@ -176,7 +201,7 @@ public class ChangeLogEntry
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 @@ public class ChangeLogEntry
{
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();
}
}

View File

@@ -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.