Skip to content

Commit

Permalink
Fix bug with URLs involving a branch name that has special characters…
Browse files Browse the repository at this point in the history
… in it
  • Loading branch information
durden committed May 5, 2016
1 parent 34fef8b commit ea3ed3b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pskb_website/filters.py
Expand Up @@ -2,6 +2,8 @@
Misc. filter tags for templates
"""

from urllib import urlencode

from flask import url_for

from . import PUBLISHED
Expand Down Expand Up @@ -57,7 +59,9 @@ def url_for_article(article, base_url=app.config['DOMAIN'], branch=u'master',

if branch != u'master':
query_str_arg = '&' if '?' in url else '?'
url = u'%s%sbranch=%s' % (url, query_str_arg, branch)
# Must encode branch name b/c it could have special characters like '+'
# for stacks like c++
url = u'%s%s%s' % (url, query_str_arg, urlencode({'branch': branch}))

return url

Expand Down

0 comments on commit ea3ed3b

Please sign in to comment.