From 0aa2376e624da1665ff5fd16a8330295b4af6f10 Mon Sep 17 00:00:00 2001 From: Ted Nathan Husted Date: Wed, 22 Nov 2006 20:45:48 +0000 Subject: [PATCH] WW-1491 Add setting to govern whether to force the initial letter of an action to lowercase. git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@478316 13f79535-47bb-0310-9956-ffa450edef68 --- .../ClasspathConfigurationProvider.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/config/ClasspathConfigurationProvider.java b/core/src/main/java/org/apache/struts2/config/ClasspathConfigurationProvider.java index 577b49b3a..72f976eba 100644 --- a/core/src/main/java/org/apache/struts2/config/ClasspathConfigurationProvider.java +++ b/core/src/main/java/org/apache/struts2/config/ClasspathConfigurationProvider.java @@ -88,6 +88,19 @@ public class ClasspathConfigurationProvider implements ConfigurationProvider { */ private String defaultParentPackage = "struts-default"; + /** + * The default page prefix (or "path"). + * Some applications may place pages under "/WEB-INF" as an extreme security precaution. + */ + private static final String FORCE_LOWER_CASE = "struts.configuration.classpath.forceLowerCase"; + + /** + * Whether to use a lowercase letter as the initial letter of an action. + * If false, actions will retain the initial uppercase letter from the Action class. + * (view.action (true) versus View.action (false)). + */ + private boolean forceLowerCase = true; + /** * Default suffix that can be used to indicate POJO "Action" classes. */ @@ -150,6 +163,9 @@ public class ClasspathConfigurationProvider implements ConfigurationProvider { defaultPagePrefix = Settings.get(DEFAULT_PAGE_PREFIX); } + if (Settings.isSet(FORCE_LOWER_CASE)) { + forceLowerCase = Settings.get(FORCE_LOWER_CASE).equalsIgnoreCase("true"); + } } /** @@ -293,8 +309,8 @@ public class ClasspathConfigurationProvider implements ConfigurationProvider { actionName = actionName.substring(0, actionName.length() - ACTION.length()); } - // Force initial letter of action to lowercase - if (actionName.length() > 1) { + // Force initial letter of action to lowercase, if desired + if ((forceLowerCase) && (actionName.length() > 1)) { int lowerPos = actionName.lastIndexOf('/') + 1; StringBuilder sb = new StringBuilder(); sb.append(actionName.substring(0, lowerPos));