Skip to content

Commit

Permalink
WW-5427 Upgrades Freemarker incompatible_improvements to version 2.3.33
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszlenart committed Oct 20, 2024
1 parent 954453b commit c3e0b9c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 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 @@ -387,7 +387,7 @@ public void testNonceOfInvalidSession() {
DoubleSelect dblSelect = new DoubleSelect(stack, req, res);
dblSelect.evaluateParams();

assertNull(dblSelect.getParameters().get("nonce"));
assertNull(dblSelect.getAttributes().get("nonce"));
}

public void testSetNullUiStaticContentPath() {
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 c3e0b9c

Please sign in to comment.