struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject struts git commit: Disallows dot in action name
Date Mon, 23 May 2016 14:03:17 GMT
Repository: struts
Updated Branches:
  refs/heads/master 880c1d54a -> 9b34a2819


Disallows dot in action name


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/9b34a281
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/9b34a281
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/9b34a281

Branch: refs/heads/master
Commit: 9b34a28190b71f73c26564ce06139aa4e4861e18
Parents: 880c1d5
Author: Lukasz Lenart <lukaszlenart@apache.org>
Authored: Mon May 23 16:02:25 2016 +0200
Committer: Lukasz Lenart <lukaszlenart@apache.org>
Committed: Mon May 23 16:03:09 2016 +0200

----------------------------------------------------------------------
 .../struts2/dispatcher/mapper/DefaultActionMapper.java  |  2 +-
 .../dispatcher/mapper/DefaultActionMapperTest.java      | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/9b34a281/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java
b/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java
index d0e89be..1396025 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java
@@ -120,7 +120,7 @@ public class DefaultActionMapper implements ActionMapper {
     protected boolean allowSlashesInActionNames = false;
     protected boolean alwaysSelectFullNamespace = false;
     protected PrefixTrie prefixTrie = null;
-    protected Pattern allowedActionNames = Pattern.compile("[a-zA-Z0-9._!/\\-]*");
+    protected Pattern allowedActionNames = Pattern.compile("^[a-zA-Z0-9_!/\\-]+((.htm[l]?)|(.action))?$");
     private boolean allowActionPrefix = false;
     private boolean allowActionCrossNamespaceAccess = false;
 

http://git-wip-us.apache.org/repos/asf/struts/blob/9b34a281/core/src/test/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapperTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapperTest.java
b/core/src/test/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapperTest.java
index 69bb7de..b51f569 100644
--- a/core/src/test/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapperTest.java
+++ b/core/src/test/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapperTest.java
@@ -163,8 +163,8 @@ public class DefaultActionMapperTest extends StrutsInternalTestCase {
 
     public void testGetMappingWithNamespaceSlash() throws Exception {
 
-        req.setupGetRequestURI("/my.hh/abc.action");
-        req.setupGetServletPath("/my.hh/abc.action");
+        req.setupGetRequestURI("/my-hh/abc.action");
+        req.setupGetServletPath("/my-hh/abc.action");
         req.setupGetAttribute(null);
         req.addExpectedGetAttributeName("javax.servlet.include.servlet_path");
 
@@ -181,7 +181,7 @@ public class DefaultActionMapperTest extends StrutsInternalTestCase {
         mapping = mapper.getMapping(req, configManager);
 
         assertEquals("", mapping.getNamespace());
-        assertEquals("my.hh/abc", mapping.getName());
+        assertEquals("my-hh/abc", mapping.getName());
     }
 
     public void testGetMappingWithUnknownNamespace() throws Exception {
@@ -855,7 +855,7 @@ public class DefaultActionMapperTest extends StrutsInternalTestCase {
             expected = t;
         }
         assertTrue(expected instanceof StrutsException);
-        assertEquals("Action [${action}] does not match allowed action names pattern [[a-zA-Z0-9._!/\\-]*]!",
expected.getMessage());
+        assertEquals("Action [${action}] does not match allowed action names pattern [" +
mapper.allowedActionNames.pattern() + "]!", expected.getMessage());
 
         actionName = "${${%{action}}}";
         try {
@@ -865,7 +865,7 @@ public class DefaultActionMapperTest extends StrutsInternalTestCase {
             expected = t;
         }
         assertTrue(expected instanceof StrutsException);
-        assertEquals("Action [${${%{action}}}] does not match allowed action names pattern
[[a-zA-Z0-9._!/\\-]*]!", expected.getMessage());
+        assertEquals("Action [${${%{action}}}] does not match allowed action names pattern
[" + mapper.allowedActionNames.pattern() + "]!", expected.getMessage());
 
         actionName = "${#foo='action',#foo}";
         try {
@@ -875,7 +875,7 @@ public class DefaultActionMapperTest extends StrutsInternalTestCase {
             expected = t;
         }
         assertTrue(expected instanceof StrutsException);
-        assertEquals("Action [${#foo='action',#foo}] does not match allowed action names
pattern [[a-zA-Z0-9._!/\\-]*]!", expected.getMessage());
+        assertEquals("Action [${#foo='action',#foo}] does not match allowed action names
pattern [" + mapper.allowedActionNames.pattern() + "]!", expected.getMessage());
 
         actionName = "test-action";
         assertEquals("test-action", mapper.cleanupActionName(actionName));


Mime
View raw message