From 2385bd1d7915e7811dfba1c78517e5d470bb1f0d Mon Sep 17 00:00:00 2001 From: Thomas Kranitsas Date: Sat, 8 Jul 2017 17:59:50 +0300 Subject: [PATCH] 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 = {