diff --git a/src/it/report-changes-generation-notEscapeText/pom.xml b/src/it/report-changes-generation-notEscapeText/pom.xml new file mode 100644 index 00000000..78ea18bc --- /dev/null +++ b/src/it/report-changes-generation-notEscapeText/pom.xml @@ -0,0 +1,107 @@ + + + + + 4.0.0 + org.apache.maven.plugins + maven-changes-plugin-test + 99.0 + Maven + jar + Test report. + + + junit + junit + 3.8.1 + test + + + + jira + http://localhost/bla + + + @project.version@ + + + + + + org.apache.maven.plugins + maven-changes-plugin + ${changesPluginVersion} + + false + + + + + + + org.apache.maven.plugins + maven-changes-plugin + ${changesPluginVersion} + + + validate-changes + pre-site + + changes-validate + + + true + + + + + + org.apache.maven.plugins + maven-site-plugin + @sitePluginVersion@ + + + + + true + + + org.apache.maven.plugins + maven-changes-plugin + @project.version@ + + + http://myjira/browse/%ISSUE% + + + + + + changes + + + + + + + + diff --git a/src/it/report-changes-generation-notEscapeText/src/changes/changes.xml b/src/it/report-changes-generation-notEscapeText/src/changes/changes.xml new file mode 100644 index 00000000..c3740e7b --- /dev/null +++ b/src/it/report-changes-generation-notEscapeText/src/changes/changes.xml @@ -0,0 +1,30 @@ + + + + + + HTML tags are not escaped, but passed as raw text. + ]]> + + + \ No newline at end of file diff --git a/src/it/report-changes-generation-notEscapeText/verify.groovy b/src/it/report-changes-generation-notEscapeText/verify.groovy new file mode 100644 index 00000000..29894d88 --- /dev/null +++ b/src/it/report-changes-generation-notEscapeText/verify.groovy @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +def report = new File(basedir, 'target/site/changes.html') +assert report.exists() + +def content = report.text + +// HTML tags in action text are escaped, and not passed as raw text +assert content.contains('HTML tags are not escaped, but passed as raw text.') diff --git a/src/it/report-changes-generation/src/changes/changes.xml b/src/it/report-changes-generation/src/changes/changes.xml index 05f523b1..cbd5d5d0 100644 --- a/src/it/report-changes-generation/src/changes/changes.xml +++ b/src/it/report-changes-generation/src/changes/changes.xml @@ -49,6 +49,9 @@ under the License. Updated dependencies. No dev action + HTML tags are escaped and not passed as raw text. + ]]> diff --git a/src/it/report-changes-generation/verify.groovy b/src/it/report-changes-generation/verify.groovy index 669f6e4d..44a6976b 100644 --- a/src/it/report-changes-generation/verify.groovy +++ b/src/it/report-changes-generation/verify.groovy @@ -40,3 +40,6 @@ assert content.contains('Thanks to External Submitter,') assert content.contains('others') // no link to empty dev value assert content.contains('-') + +// HTML tags in action text are escaped, and not passed as raw text +assert content.contains('<strong>HTML tags</strong> are escaped and not passed as raw text.') diff --git a/src/main/java/org/apache/maven/plugins/changes/ChangesReport.java b/src/main/java/org/apache/maven/plugins/changes/ChangesReport.java index ba98d6b3..fba4028c 100644 --- a/src/main/java/org/apache/maven/plugins/changes/ChangesReport.java +++ b/src/main/java/org/apache/maven/plugins/changes/ChangesReport.java @@ -75,6 +75,21 @@ public class ChangesReport extends AbstractChangesReport { @Parameter(property = "changes.addActionDate", defaultValue = "false") private boolean addActionDate; + /** + * Whether the change description should be escaped (default), or passed as is to the report renderer. + * + *

+ * Example: If you are generating the changes report as HTML, and want HTML tags included in your changes XML + * (like <b>Bold</b>) to be interpreted correctly in the generated output, you have to set this + * parameter to false. You can use a <![CDATA[...]]> block in your changes XML to + * enclose descriptions with HTML tags. + *

+ * + * @since 3.0 + */ + @Parameter(defaultValue = "true") + private boolean escapeText; + /** * The directory for interpolated changes.xml. * @@ -243,6 +258,7 @@ public void executeReport(Locale locale) throws MavenReportException { } report.setLinkToFeed(feedGenerated); + report.setEscapeText(escapeText); report.render(); diff --git a/src/main/java/org/apache/maven/plugins/changes/ChangesReportRenderer.java b/src/main/java/org/apache/maven/plugins/changes/ChangesReportRenderer.java index 555dddf5..95148f2e 100644 --- a/src/main/java/org/apache/maven/plugins/changes/ChangesReportRenderer.java +++ b/src/main/java/org/apache/maven/plugins/changes/ChangesReportRenderer.java @@ -73,6 +73,8 @@ public class ChangesReportRenderer extends AbstractIssuesReportRenderer { private boolean linkToFeed; + private boolean escapeText; + public ChangesReportRenderer(Sink sink, ResourceBundle bundleName, ChangesXML changesXML) { super(sink, bundleName); this.issueLinksPerSystem = new HashMap<>(); @@ -106,6 +108,10 @@ public void setLinkToFeed(boolean generateLinkTofeed) { this.linkToFeed = generateLinkTofeed; } + public void setEscapeText(boolean escapeText) { + this.escapeText = escapeText; + } + /** * Checks whether links to the issues can be generated for the given system. * @@ -159,7 +165,11 @@ private void constructAction(Action action) { String actionDescription = action.getAction(); - text(actionDescription); + if (escapeText || StringUtils.isEmpty(actionDescription)) { + text(actionDescription); + } else { + sink.rawText(actionDescription); + } // no null check needed classes from modello return a new ArrayList if (StringUtils.isNotEmpty(action.getIssue())