struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mr...@apache.org
Subject svn commit: r491545 - in /struts/struts2/trunk/core/src: main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java test/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapperTest.java
Date Mon, 01 Jan 2007 08:49:15 GMT
Author: mrdon
Date: Mon Jan  1 00:49:14 2007
New Revision: 491545

URL: http://svn.apache.org/viewvc?view=rev&rev=491545
Log:
Added better detection of existing namespaces by requiring an ending slash on the match
WW-1523

Modified:
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapperTest.java

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java?view=diff&rev=491545&r1=491544&r2=491545
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java
(original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java
Mon Jan  1 00:49:14 2007
@@ -349,7 +349,7 @@
             for (Iterator i = config.getPackageConfigs().values().iterator(); i
                     .hasNext();) {
                 String ns = ((PackageConfig) i.next()).getNamespace();
-                if (ns != null && prefix.startsWith(ns)) {
+                if (ns != null && prefix.startsWith(ns + "/")) {
                     if (ns.length() > namespace.length()) {
                         namespace = ns;
                     }

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapperTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapperTest.java?view=diff&rev=491545&r1=491544&r2=491545
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapperTest.java
(original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapperTest.java
Mon Jan  1 00:49:14 2007
@@ -116,6 +116,29 @@
         assertEquals("foo/actionName", mapping.getName());
         assertNull(mapping.getMethod());      
     }
+    
+    public void testGetMappingWithNamespaceSlash() throws Exception {
+
+        req.setupGetRequestURI("/my.hh/abc.action");
+        req.setupGetServletPath("/my.hh/abc.action");
+        req.setupGetAttribute(null);
+        req.addExpectedGetAttributeName("javax.servlet.include.servlet_path");
+
+        DefaultActionMapper mapper = new DefaultActionMapper();
+        ActionMapping mapping = mapper.getMapping(req, configManager);
+
+        assertEquals("", mapping.getNamespace());
+        assertEquals("abc", mapping.getName());
+        
+        req.setupGetAttribute(null);
+        req.addExpectedGetAttributeName("javax.servlet.include.servlet_path");
+        mapper = new DefaultActionMapper();
+        mapper.setSlashesInActionNames("true");
+        mapping = mapper.getMapping(req, configManager);
+
+        assertEquals("", mapping.getNamespace());
+        assertEquals("my.hh/abc", mapping.getName());
+    }
 
     public void testGetMappingWithUnknownNamespace() throws Exception {
         setUp();



Mime
View raw message