-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes incorrectly encoded url current url #6685
Conversation
* url in question /%EF%AC%81?foo=bar&bz=%AC%81 * This is a unicode character, which can't be decoded from ascii. Jinja templates will handle this if it's unicode, or if it's hex encoded ascii, but can't take a non-unicode string in python 2 and put this in a template. * The querystring was being quoted, which is incorrect, as: 1) the special characters in the query string mean something 2) The rest of the querystring is already quoted. This makes it double quoted, as seen in the datastore file * We don't want to unquote urls before putting them in the template anyway. * There was s further error passing this unicode path to the template resolution, where in posix path, it fails: ``` File '/usr/lib/ckan/default/lib/python2.7/posixpath.py', line 73 in join path += '/' + b UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 1: ordinal not in range(128) ``` The solution here is to make sure it's unicode passed into the function.
Let's search usage of CKAN_CURRENT_URL on popular extensions and mention this on the release notes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds good @EricSoroos but can you add the tiny suggestion to make the tests pass, and also submit the same patch for master and 2.9? Thanks
ckan/controllers/template.py
Outdated
@@ -29,6 +29,10 @@ def view(self, url): | |||
By default this controller aborts the request with a 404 (Not | |||
Found) | |||
""" | |||
try: | |||
url = unicode(url.encode('utf-8')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
url = unicode(url.encode('utf-8')) | |
url = unicode(url.encode(u'utf-8')) |
@EricSoroos do you want to have a look at this? |
@amercader this looks good to me but is against the 2.8 branch. If this code doesn't exist on master anymore would we still want something similar for 2.9? |
@EricSoroos This needs to be fixed in master as well:
Can you send a PR against master with these fixes? Thanks |
@amercader Will do. |
Fixes #6684
Proposed fixes:
ascii. Jinja templates will handle this if it's unicode, or if it's
hex encoded ascii, but can't take a non-unicode string in python 2 and
put this in a template.
double quoted, as seen in the datastore file
anyway.
resolution, where in posix path, it fails:
The solution here is to make sure it's unicode passed into the
function.
Features:
Please [X] all the boxes above that apply