diff --git a/changelog/src/main/org/apache/maven/changelog/ChangeLogEntry.java b/changelog/src/main/org/apache/maven/changelog/ChangeLogEntry.java index 6692ad2f..653a44b3 100644 --- a/changelog/src/main/org/apache/maven/changelog/ChangeLogEntry.java +++ b/changelog/src/main/org/apache/maven/changelog/ChangeLogEntry.java @@ -68,10 +68,35 @@ import java.util.Vector; * @task add time of change to the entry * @task investigate betwixt for toXML method * @author dIon Gillard - * @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 < entity + */ + public static final String LESS_THAN_ENTITY = "<"; + + /** + * Escaped > entity + */ + public static final String GREATER_THAN_ENTITY = ">"; + + /** + * Escaped & entity + */ + public static final String AMPERSAND_ENTITY = "&"; + + /** + * Escaped ' entity + */ + public static final String APOSTROPHE_ENTITY = "'"; + + /** + * Escaped " entity + */ + public static final String QUOTE_ENTITY = """; + /** * Formatter used by the getDateFormatted method. */ @@ -176,7 +201,7 @@ public class ChangeLogEntry ChangeLogFile file = (ChangeLogFile) e.nextElement(); buffer.append("\t\t\n") .append("\t\t\t") - .append(file.getName()) + .append(escapeValue(file.getName())) .append("\n") .append("\t\t\t") .append(file.getRevision()) @@ -278,5 +303,47 @@ public class ChangeLogEntry { return TIME_FORMAT.format(getDate()); } - + + /** + *

Escape the toString of the given object. + * For use in an attribute value.

+ * + * swiped from jakarta-commons/betwixt -- XMLUtils.java + * + * @param value escape value.toString() + * @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 ': + 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(); + } } diff --git a/changelog/xdocs/changes.xml b/changelog/xdocs/changes.xml index 67e7e100..28b361ba 100644 --- a/changelog/xdocs/changes.xml +++ b/changelog/xdocs/changes.xml @@ -8,6 +8,9 @@ + + Fixed MAVEN-425. Escape filename. + fixed MAVEN-493. I register reports only if source, test,... exists. So, corresponding entrys in menu will appear only if reports are registered.