diff --git a/Changelog.md b/Changelog.md index 61b3fa3c6..50d31aeea 100644 --- a/Changelog.md +++ b/Changelog.md @@ -8,6 +8,7 @@ * Delegate parent_author to the target of a RelayableRetraction * Do not fail on receiving a SignedRetraction via the public route * Pass the real values to stderr_path and stdout_path in unicorn.rb since it runs a case statement on them. +* Decode tag name before passing it into a TagFollowingAction [#4027](https://github.com/diaspora/diaspora/issues/4027) ## Refactor diff --git a/app/assets/javascripts/app/router.js b/app/assets/javascripts/app/router.js index e00d3e4dd..42c8d1a4e 100644 --- a/app/assets/javascripts/app/router.js +++ b/app/assets/javascripts/app/router.js @@ -77,7 +77,7 @@ app.Router = Backbone.Router.extend({ if(name) { var followedTagsAction = new app.views.TagFollowingAction( - {tagText: name} + {tagText: decodeURIComponent(name)} ); $("#author_info").prepend(followedTagsAction.render().el) } diff --git a/spec/javascripts/app/router_spec.js b/spec/javascripts/app/router_spec.js new file mode 100644 index 000000000..e116daaf4 --- /dev/null +++ b/spec/javascripts/app/router_spec.js @@ -0,0 +1,19 @@ +describe('app.Router', function () { + describe('followed_tags', function() { + it('decodes name before passing it into TagFollowingAction', function () { + var followed_tags = spyOn(app.router, 'followed_tags').andCallThrough(); + var tag_following_action = spyOn(app.views, 'TagFollowingAction').andCallFake(function(data) { + return {render: function() { return {el: ""}}}; + }); + spyOn(window.history, 'pushState').andCallFake(function (data, title, url) { + var route = app.router._routeToRegExp("tags/:name"); + var args = app.router._extractParameters(route, url.replace(/^\//, "")); + app.router.followed_tags(args[0]); + }); + window.preloads = {tagFollowings: []}; + app.router.navigate('/tags/'+encodeURIComponent('օբյեկտիվ')); + expect(followed_tags).toHaveBeenCalled(); + expect(tag_following_action).toHaveBeenCalledWith({tagText: 'օբյեկտիվ'}); + }); + }); +});