Skip to content

Commit

Permalink
prevent double encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasKranitsas committed Jul 8, 2017
1 parent c3e7451 commit 2385bd1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 0 additions & 3 deletions app/profile/profile.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 8 additions & 1 deletion app/topcoder.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

1 comment on commit 2385bd1

@birdofpreyru
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ThomasKranitsas I won't be able to test it before tomorrow, but it already does not look good to me. You force-decode everything and write it URL. What if member handle contains URL encoded /? It will surely break your code.

Please sign in to comment.