WICKET-4588 non-relative redirects do not work properly

Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/5f55334a
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/5f55334a
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/5f55334a

Branch: refs/heads/wicket-1.5.x
Commit: 5f55334a9703e57c4656dd59cc5a0313f2e0924b
Parents: 2a6a288
Author: Martin Tzvetanov Grigorov <[email protected]>
Authored: Fri Jun 15 11:52:53 2012 +0300
Committer: Martin Tzvetanov Grigorov <[email protected]>
Committed: Fri Jun 15 11:52:53 2012 +0300

----------------------------------------------------------------------
 .../java/org/apache/wicket/ajax/wicket-ajax.js     |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/5f55334a/wicket-core/src/main/java/org/apache/wicket/ajax/wicket-ajax.js
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/wicket-ajax.js 
b/wicket-core/src/main/java/org/apache/wicket/ajax/wicket-ajax.js
index 0bfa3fc..caf3c3b 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/wicket-ajax.js
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/wicket-ajax.js
@@ -992,14 +992,17 @@ Wicket.Ajax.Request.prototype = {
                                // the redirect header was set, go to new url
                                if (typeof(redirectUrl) != "undefined" && 
redirectUrl != null && redirectUrl != "") {
                                        t.onreadystatechange = 
Wicket.emptyFunction;
-                                       
+
                                        // In case the page isn't really 
redirected. For example say the redirect is to an octet-stream.
                                        // A file download popup will appear 
but the page in the browser won't change.                                  
                                        this.done();
                                        this.successHandler();
-                                       
+
+                                       var rhttp  = /^http:\/\//,  // checks 
whether the string starts with http://
+                                           rhttps = /^https:\/\//; // checks 
whether the string starts with https://
+
                     // support/check for non-relative redirectUrl like as 
provided and needed in a portlet context
-                                       if 
(redirectUrl.charAt(0)==('/')||redirectUrl.match("^http://";)=="http://";||redirectUrl.match("^https://";)=="https://";)
 {
+                                       if (redirectUrl.charAt(0)==('/') || 
rhttp.test(redirectUrl) || rhttps.test(redirectUrl)) {
                                            window.location = redirectUrl;
                                        }
                                        else {

Reply via email to