Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id B2531200B45 for ; Fri, 15 Jul 2016 15:18:45 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id B0CF6160A87; Fri, 15 Jul 2016 13:18:45 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 04195160A6C for ; Fri, 15 Jul 2016 15:18:44 +0200 (CEST) Received: (qmail 34204 invoked by uid 500); 15 Jul 2016 13:18:30 -0000 Mailing-List: contact commits-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list commits@struts.apache.org Received: (qmail 32870 invoked by uid 99); 15 Jul 2016 13:18:30 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Jul 2016 13:18:29 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id CB52EDFF46; Fri, 15 Jul 2016 13:18:29 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: lukaszlenart@apache.org To: commits@struts.apache.org Date: Fri, 15 Jul 2016 13:19:07 -0000 Message-Id: <5a59e9530a1746f6b44ee06f88790176@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [40/50] [abbrv] struts git commit: WW-4585 Struts2 Rest plugin doesn't handle JSESSIONID with DMI archived-at: Fri, 15 Jul 2016 13:18:45 -0000 WW-4585 Struts2 Rest plugin doesn't handle JSESSIONID with DMI Project: http://git-wip-us.apache.org/repos/asf/struts/repo Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/5eaef08e Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/5eaef08e Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/5eaef08e Branch: refs/heads/master Commit: 5eaef08e52fbb46e1659b46435172d8e52b8b090 Parents: dd849e8 Author: Aleksandr Mashchenko Authored: Thu Jan 14 20:01:57 2016 +0200 Committer: Lukasz Lenart Committed: Tue Jan 19 16:19:20 2016 +0100 ---------------------------------------------------------------------- .../apache/struts2/rest/RestActionMapper.java | 15 ++++++++-- .../struts2/rest/RestActionMapperTest.java | 29 ++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts/blob/5eaef08e/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java ---------------------------------------------------------------------- diff --git a/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java b/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java index 816843a..d25b725 100644 --- a/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java +++ b/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java @@ -308,9 +308,20 @@ public class RestActionMapper extends DefaultActionMapper { private void handleDynamicMethodInvocation(ActionMapping mapping, String name) { int exclamation = name.lastIndexOf("!"); if (exclamation != -1) { - mapping.setName(name.substring(0, exclamation)); + String actionName = name.substring(0, exclamation); + String actionMethod = name.substring(exclamation + 1); + + // WW-4585 + // add any ; appendix to name, it will be handled later in getMapping method + int scPos = actionMethod.indexOf(';'); + if (scPos != -1) { + actionName = actionName + actionMethod.substring(scPos); + actionMethod = actionMethod.substring(0, scPos); + } + + mapping.setName(actionName); if (allowDynamicMethodCalls) { - mapping.setMethod(name.substring(exclamation + 1)); + mapping.setMethod(actionMethod); } else { mapping.setMethod(null); } http://git-wip-us.apache.org/repos/asf/struts/blob/5eaef08e/plugins/rest/src/test/java/org/apache/struts2/rest/RestActionMapperTest.java ---------------------------------------------------------------------- diff --git a/plugins/rest/src/test/java/org/apache/struts2/rest/RestActionMapperTest.java b/plugins/rest/src/test/java/org/apache/struts2/rest/RestActionMapperTest.java index 8d39cc1..9903265 100644 --- a/plugins/rest/src/test/java/org/apache/struts2/rest/RestActionMapperTest.java +++ b/plugins/rest/src/test/java/org/apache/struts2/rest/RestActionMapperTest.java @@ -179,6 +179,35 @@ public class RestActionMapperTest extends TestCase { assertEquals("show", mapping.getMethod()); } + public void testGetJsessionIdSemicolonMappingWithMethod() throws Exception { + req.setRequestURI("/myapp/animals/dog/fido!update;jsessionid=29fefpv23do1g"); + req.setServletPath("/animals/dog/fido"); + req.setMethod("GET"); + + ActionMapping mapping = mapper.getMapping(req, configManager); + + assertEquals("/animals", mapping.getNamespace()); + assertEquals("dog", mapping.getName()); + assertEquals("fido", ((String[]) mapping.getParams().get("id"))[0]); + assertEquals("show", mapping.getMethod()); + } + + public void testGetJsessionIdSemicolonMappingWithMethodAllowDMI() throws Exception { + req.setRequestURI("/myapp/animals/dog/fido!update;jsessionid=29fefpv23do1g"); + req.setServletPath("/animals/dog/fido"); + req.setMethod("GET"); + + // allow DMI + mapper.setAllowDynamicMethodCalls("true"); + + ActionMapping mapping = mapper.getMapping(req, configManager); + + assertEquals("/animals", mapping.getNamespace()); + assertEquals("dog", mapping.getName()); + assertEquals("fido", ((String[]) mapping.getParams().get("id"))[0]); + assertEquals("update", mapping.getMethod()); + } + public void testParseNameAndNamespace() { tryUri("/foo/23", "", "foo/23"); tryUri("/foo/", "", "foo/");