Skip to content

Commit

Permalink
Merge pull request #1088 from apache/feature/WW-5427-incompatible-imp…
Browse files Browse the repository at this point in the history
…rovements

WW-5427 Upgrades Freemarker incompatible_improvements to version 2.3.33
  • Loading branch information
lukaszlenart authored Oct 21, 2024
2 parents 3d255ca + c3e0b9c commit 9130e31
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ protected Configuration createConfiguration(ServletContext servletContext) throw
}

protected Version getFreemarkerVersion(ServletContext servletContext) {
Version incompatibleImprovements = Configuration.VERSION_2_3_28;
Version incompatibleImprovements = Configuration.VERSION_2_3_33;

String incompatibleImprovementsParam = servletContext.getInitParameter("freemarker." + Configuration.INCOMPATIBLE_IMPROVEMENTS_KEY_SNAKE_CASE);
if (incompatibleImprovementsParam != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void testTemplateLoaderBaseOnFile() throws Exception {
servletContext.setAttribute(FreemarkerManager.CONFIG_SERVLET_CONTEXT_KEY, null);

String tmpPath = "file://" + FileUtils.getTempDirectoryPath();

// when
manager.load(servletContext, tmpPath);

Expand All @@ -70,7 +70,7 @@ public void testIncompatibleImprovementsByOverriding() throws Exception {
FreemarkerManager manager = new FreemarkerManager() {
@Override
protected Version getFreemarkerVersion(ServletContext servletContext) {
return Configuration.VERSION_2_3_0;
return Configuration.VERSION_2_3_33;
}
};
container.inject(manager);
Expand All @@ -79,7 +79,7 @@ protected Version getFreemarkerVersion(ServletContext servletContext) {
manager.init(servletContext);

// then
assertEquals(Configuration.VERSION_2_3_0, manager.config.getIncompatibleImprovements());
assertEquals(Configuration.VERSION_2_3_33, manager.config.getIncompatibleImprovements());
}

public void testIncompatibleImprovementsWithTemplate() throws Exception {
Expand All @@ -91,26 +91,27 @@ public void testIncompatibleImprovementsWithTemplate() throws Exception {

// when
Writer out = new StringWriter();
Map<String, String> model = new HashMap<>();
Map<String, String> model = new HashMap<>();
model.put("error", "It's an error message");

tpl.process(model, out);

// then
assertEquals(Configuration.VERSION_2_3_33, configuration.getIncompatibleImprovements());
assertEquals("<input type=\"text\" onclick=\"this.alert('It&#39;s an error message')\"/>", out.toString());
}

public void testIncompatibleImprovementsByServletContext() throws Exception {
// given
servletContext.setInitParameter("freemarker.incompatible_improvements", "2.3.0");
servletContext.setInitParameter("freemarker.incompatible_improvements", "2.3.32");
FreemarkerManager manager = new FreemarkerManager();
container.inject(manager);

// when
manager.init(servletContext);

// then
assertEquals(Configuration.VERSION_2_3_0, manager.config.getIncompatibleImprovements());
assertEquals(Configuration.VERSION_2_3_32, manager.config.getIncompatibleImprovements());
}
}

Expand All @@ -119,5 +120,5 @@ class DummyFreemarkerManager extends FreemarkerManager {
public void load(StrutsMockServletContext servletContext, String path) {
createTemplateLoader(servletContext, path);
}

}

0 comments on commit 9130e31

Please sign in to comment.