Skip to content

Commit 637ad1c

Browse files
committed
Narrows class resolver
1 parent 1a8111e commit 637ad1c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.opensymphony.xwork2.util.ClassLoaderUtil;
2929
import com.opensymphony.xwork2.util.ValueStack;
3030
import freemarker.cache.*;
31+
import freemarker.core.TemplateClassResolver;
3132
import freemarker.ext.jsp.TaglibFactory;
3233
import freemarker.ext.servlet.HttpRequestHashModel;
3334
import freemarker.ext.servlet.HttpRequestParametersHashModel;
@@ -318,16 +319,23 @@ protected Configuration createConfiguration(ServletContext servletContext) throw
318319
configuration.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
319320

320321
if (mruMaxStrongSize > 0) {
322+
LOG.debug("Sets Configuration.CACHE_STORAGE_KEY to strong:{}", mruMaxStrongSize);
321323
configuration.setSetting(Configuration.CACHE_STORAGE_KEY, "strong:" + mruMaxStrongSize);
322324
}
323325
if (templateUpdateDelay != null) {
326+
LOG.debug("Sets Configuration.TEMPLATE_UPDATE_DELAY_KEY to {}", templateUpdateDelay);
324327
configuration.setSetting(Configuration.TEMPLATE_UPDATE_DELAY_KEY, templateUpdateDelay);
325328
}
326329
if (encoding != null) {
330+
LOG.debug("Sets DefaultEncoding to {}", encoding);
327331
configuration.setDefaultEncoding(encoding);
328332
}
333+
LOG.debug("Disabled localized lookups");
329334
configuration.setLocalizedLookup(false);
335+
LOG.debug("Enabled whitespace stripping");
330336
configuration.setWhitespaceStripping(true);
337+
LOG.debug("Sets NewBuiltinClassResolver to TemplateClassResolver.SAFER_RESOLVER");
338+
configuration.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);
331339

332340
return configuration;
333341
}

0 commit comments

Comments
 (0)