From eeb390862c78c6938ae056b5eefd75a6bbb520f8 Mon Sep 17 00:00:00 2001 From: "zia.fazal@arbisoft.com" Date: Mon, 24 Feb 2020 12:40:12 +0500 Subject: [PATCH] Use encodeURIComponent instead of encodeURI We should use encodeURIComponent instead of encodeURI when encoding part of uri like querystring. encodeURI does not encode `+` sign. For example a query string parameter like `scope=user_id+profile+email` is not encoded by `encodeURI` which results in invalid url on select multiple enterprise page. Fixed broken test --- lms/static/js/spec/student_account/multiple_enterprise_spec.js | 2 +- lms/static/js/student_account/multiple_enterprise.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lms/static/js/spec/student_account/multiple_enterprise_spec.js b/lms/static/js/spec/student_account/multiple_enterprise_spec.js index 86ba7d504c..0c7d8be569 100644 --- a/lms/static/js/spec/student_account/multiple_enterprise_spec.js +++ b/lms/static/js/spec/student_account/multiple_enterprise_spec.js @@ -9,7 +9,7 @@ define([ describe('MultipleEnterpriseInterface', function() { var LEARNER_URL = '/enterprise/api/v1/enterprise-learner/?username=test-learner', NEXT_URL = '/dashboard', - REDIRECT_URL = '/enterprise/select/active/?success_url=/dashboard'; + REDIRECT_URL = '/enterprise/select/active/?success_url=%2Fdashboard'; beforeEach(function() { // Mock the redirect call diff --git a/lms/static/js/student_account/multiple_enterprise.js b/lms/static/js/student_account/multiple_enterprise.js index 94046fdf2c..9dadd3d0a7 100644 --- a/lms/static/js/student_account/multiple_enterprise.js +++ b/lms/static/js/student_account/multiple_enterprise.js @@ -18,7 +18,7 @@ * @param {string} nextUrl The URL to redirect to after multiple enterprise selection. */ check: function(nextUrl) { - var redirectUrl = this.urls.multipleEnterpriseUrl + encodeURI(nextUrl); + var redirectUrl = this.urls.multipleEnterpriseUrl + encodeURIComponent(nextUrl); var username = Utils.userFromEdxUserCookie().username; var next = nextUrl || '/'; $.ajax({