From c3e74510051ea78c42014034c065e6b194b2c6c7 Mon Sep 17 00:00:00 2001 From: Thomas Kranitsas Date: Fri, 7 Jul 2017 18:07:32 +0300 Subject: [PATCH 1/2] Fix issue with urlencoded user handles --- app/profile/profile.routes.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/profile/profile.routes.js b/app/profile/profile.routes.js index 21a01fa99..bcbd32f27 100644 --- a/app/profile/profile.routes.js +++ b/app/profile/profile.routes.js @@ -25,6 +25,9 @@ import angular from 'angular' controller: 'ProfileCtrl as profileVm', resolve: { userHandle: ['$stateParams', function($stateParams) { + if (decodeURIComponent($stateParams.userHandle) !== $stateParams.userHandle) { + return decodeURIComponent($stateParams.userHandle) + } return $stateParams.userHandle }], profile: ['userHandle', 'ProfileService', function(userHandle, ProfileService) { From 2385bd1d7915e7811dfba1c78517e5d470bb1f0d Mon Sep 17 00:00:00 2001 From: Thomas Kranitsas Date: Sat, 8 Jul 2017 17:59:50 +0300 Subject: [PATCH 2/2] prevent double encoding --- app/profile/profile.routes.js | 3 --- app/topcoder.routes.js | 9 ++++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/profile/profile.routes.js b/app/profile/profile.routes.js index bcbd32f27..21a01fa99 100644 --- a/app/profile/profile.routes.js +++ b/app/profile/profile.routes.js @@ -25,9 +25,6 @@ import angular from 'angular' controller: 'ProfileCtrl as profileVm', resolve: { userHandle: ['$stateParams', function($stateParams) { - if (decodeURIComponent($stateParams.userHandle) !== $stateParams.userHandle) { - return decodeURIComponent($stateParams.userHandle) - } return $stateParams.userHandle }], profile: ['userHandle', 'ProfileService', function(userHandle, ProfileService) { diff --git a/app/topcoder.routes.js b/app/topcoder.routes.js index bdeaef130..7b6146dc0 100644 --- a/app/topcoder.routes.js +++ b/app/topcoder.routes.js @@ -28,7 +28,14 @@ import moment from 'moment' if (path.indexOf('?') > -1) { return path.replace('?', '/?') } - $location.replace().path(path + '/') + // prevent double encoding + path = path.split('/') + for (var i = 0; i < path.length; i++) { + while (decodeURIComponent(path[i]) !== path[i]) { + path[i] = decodeURIComponent(path[i]) + } + } + $location.replace().path(path.join('/') + '/') }) var states = {