Return-Path: X-Original-To: apmail-struts-commits-archive@minotaur.apache.org Delivered-To: apmail-struts-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7C3F910D02 for ; Thu, 19 Mar 2015 08:57:28 +0000 (UTC) Received: (qmail 42222 invoked by uid 500); 19 Mar 2015 08:50:01 -0000 Delivered-To: apmail-struts-commits-archive@struts.apache.org Received: (qmail 42124 invoked by uid 500); 19 Mar 2015 08:50:01 -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 41508 invoked by uid 99); 19 Mar 2015 08:50:01 -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; Thu, 19 Mar 2015 08:50:01 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 8FC3EE190C; Thu, 19 Mar 2015 08:50:00 +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: Thu, 19 Mar 2015 08:50:04 -0000 Message-Id: In-Reply-To: <3930a6e126064d77b749c36319b92573@git.apache.org> References: <3930a6e126064d77b749c36319b92573@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [05/28] struts git commit: WW-4448 Strips params and replaces spaces WW-4448 Strips params and replaces spaces Project: http://git-wip-us.apache.org/repos/asf/struts/repo Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/0f44e11c Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/0f44e11c Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/0f44e11c Branch: refs/heads/master Commit: 0f44e11cd1f3cff51ed4a2a10dec593d8822ade2 Parents: e3428c5 Author: Lukasz Lenart Authored: Wed Jan 21 08:46:49 2015 +0100 Committer: Lukasz Lenart Committed: Wed Jan 21 08:46:49 2015 +0100 ---------------------------------------------------------------------- .../dispatcher/ServletRedirectResult.java | 6 +++- .../dispatcher/ServletRedirectResultTest.java | 30 ++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts/blob/0f44e11c/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java b/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java index b6cd282..60f5584 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/ServletRedirectResult.java @@ -272,7 +272,11 @@ public class ServletRedirectResult extends StrutsResultSupport implements Reflec */ protected boolean isPathUrl(String url) { try { - URI uri = URI.create(url); + String rawUrl = url; + if (url.contains("?")) { + rawUrl = url.substring(0, url.indexOf("?")); + } + URI uri = URI.create(rawUrl); if (uri.isAbsolute()) { URL validUrl = uri.toURL(); if (LOG.isDebugEnabled()) { http://git-wip-us.apache.org/repos/asf/struts/blob/0f44e11c/core/src/test/java/org/apache/struts2/dispatcher/ServletRedirectResultTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/struts2/dispatcher/ServletRedirectResultTest.java b/core/src/test/java/org/apache/struts2/dispatcher/ServletRedirectResultTest.java index 56cfe9d..ab40dfc 100644 --- a/core/src/test/java/org/apache/struts2/dispatcher/ServletRedirectResultTest.java +++ b/core/src/test/java/org/apache/struts2/dispatcher/ServletRedirectResultTest.java @@ -100,6 +100,36 @@ public class ServletRedirectResultTest extends StrutsInternalTestCase implements } } + public void testFullUrlRedirectWithSpaces() { + view.setLocation("http://localhost/bar/foo some.pdf"); + responseMock.expectAndReturn("encodeRedirectURL", C.args(C.eq("http://localhost/bar/foo some.pdf")), "http://localhost/bar/foo some.pdf"); + responseMock.expect("sendRedirect", C.args(C.eq("http://localhost/bar/foo some.pdf"))); + + try { + view.execute(ai); + requestMock.verify(); + responseMock.verify(); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + + public void testFullUrlRedirectWithParams() { + view.setLocation("http://localhost/bar/foo.action?param=1¶m 2=3"); + responseMock.expectAndReturn("encodeRedirectURL", C.args(C.eq("http://localhost/bar/foo.action?param=1¶m 2=3")), "http://localhost/bar/foo.action?param=1¶m 2=3"); + responseMock.expect("sendRedirect", C.args(C.eq("http://localhost/bar/foo.action?param=1¶m 2=3"))); + + try { + view.execute(ai); + requestMock.verify(); + responseMock.verify(); + } catch (Exception e) { + e.printStackTrace(); + fail(); + } + } + public void testAbsoluteRedirect303() { view.setLocation("/bar/foo.jsp"); view.setStatusCode(303);