From e98b92e57756d806164e41720f7bdea56167723b Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Tue, 15 Nov 2016 17:21:03 +0100 Subject: [PATCH] fix redirection after login where there are many parameters --- .../java/it/user/LocalAuthenticationTest.java | 1 + ...rl_with_parameters_after_direct_login.html | 68 +++++++++++++++++++ .../WEB-INF/app/views/sessions/_form.html.erb | 2 +- 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 it/it-tests/src/test/resources/user/LocalAuthenticationTest/redirect_to_original_url_with_parameters_after_direct_login.html diff --git a/it/it-tests/src/test/java/it/user/LocalAuthenticationTest.java b/it/it-tests/src/test/java/it/user/LocalAuthenticationTest.java index 76c601b0e1c..2befdda21ee 100644 --- a/it/it-tests/src/test/java/it/user/LocalAuthenticationTest.java +++ b/it/it-tests/src/test/java/it/user/LocalAuthenticationTest.java @@ -214,6 +214,7 @@ public class LocalAuthenticationTest { "/user/LocalAuthenticationTest/redirect_to_login_when_not_enough_privilege.html", // SONAR-2132 "/user/LocalAuthenticationTest/redirect_to_original_url_after_direct_login.html", + "/user/LocalAuthenticationTest/redirect_to_original_url_with_parameters_after_direct_login.html", // SONAR-2009 "/user/LocalAuthenticationTest/redirect_to_original_url_after_indirect_login.html").build()).runOn(ORCHESTRATOR); diff --git a/it/it-tests/src/test/resources/user/LocalAuthenticationTest/redirect_to_original_url_with_parameters_after_direct_login.html b/it/it-tests/src/test/resources/user/LocalAuthenticationTest/redirect_to_original_url_with_parameters_after_direct_login.html new file mode 100644 index 00000000000..d10513fedd4 --- /dev/null +++ b/it/it-tests/src/test/resources/user/LocalAuthenticationTest/redirect_to_original_url_with_parameters_after_direct_login.html @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
open/sessions/logout
open/projects?gate=OK&reliability=1&security=1
waitForTextglobal-navigation*Log in*
clicklink=Log in
waitForTextcontent*Log In to SonarQube*
typeid=loginadmin
typeid=passwordadmin
clickAndWaitcommit
waitForElementPresentcss=.js-user-authenticated
waitForTextcss=.navbar*Administrator*
assertLocation*/projects?gate=OK&reliability=1&security=1
+ + diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/sessions/_form.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/sessions/_form.html.erb index 9a5399f6e98..3f1c87f5977 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/sessions/_form.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/sessions/_form.html.erb @@ -67,7 +67,7 @@ $("#login_form").modalForm({ success: function () { - window.location = '<%= h(@return_to) -%>' + $('[name="return_to_anchor"]').val(); + window.location = '<%= escape_javascript @return_to -%>' + $('[name="return_to_anchor"]').val(); }, error: function () { $('.alert-flash').addClass('hidden'); -- 2.39.5