Skip to content
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

[superseded ignore] 500 on non-ascii url #808

Closed
wants to merge 1 commit into from

Conversation

tobes
Copy link
Contributor

@tobes tobes commented Apr 24, 2013

Hi.

If i point my webbrowser to eg.
http://datahub.io/r%C3%A4ksm%C3%B6rg%C3%A5s

Instead of giving me a 404 it gives me a 500 and sends a stacktrace to the configured admin.

@ghost ghost assigned amercader Apr 24, 2013
@tobes
Copy link
Contributor

tobes commented Apr 24, 2013

@amercader I've assigned this to you in case you feel we should take it for 2.0 - It feels like it'd be no harm to take it

@amercader
Copy link
Member

If I'm not mistaken, your fix only silences the exception but does not fix the fact that we can not use unicode names on templates. Something like this would perhaps be better:

diff --git a/ckan/lib/render.py b/ckan/lib/render.py
index e0ef0a9..3ad60ae 100644
--- a/ckan/lib/render.py
+++ b/ckan/lib/render.py
@@ -10,7 +10,7 @@ def find_template(template_name):
     returns the full path is it exists. '''
     template_paths = config['pylons.app_globals'].template_paths
     for path in template_paths:
-        if os.path.exists(os.path.join(path, template_name)):
+        if os.path.exists(os.path.join(path, template_name.encode('utf-8'))):
             return os.path.join(path, template_name)

 def template_type(template_path):
diff --git a/ckan/lib/base.py b/ckan/lib/base.py
index 0fd783c..40cdd5d 100644
--- a/ckan/lib/base.py
+++ b/ckan/lib/base.py
@@ -130,7 +130,7 @@ def render(template_name, extra_vars=None, cache_key=None, cache_type=None,
             return render_jinja2(template_name, globs)

         # Genshi templates
-        template = globs['app_globals'].genshi_loader.load(template_name,
+        template = globs['app_globals'].genshi_loader.load(template_name.encode('utf-8'),
                                                            cls=loader_class)
         stream = template.generate(**globs)

This way you get 404 and can have templates named ckan/templates/räksmörgås.html

@tobes
Copy link
Contributor

tobes commented Apr 29, 2013

@amercader yeah that is a much better solution. do you want me to make it into a pull request? If you want to do it feel free and assign me and I'll merge it

@ghost ghost assigned tobes Apr 29, 2013
@amercader
Copy link
Member

@tobes, thanks a pr with my patch would be great

tobes added a commit that referenced this pull request Apr 29, 2013
amercader added a commit that referenced this pull request May 6, 2013
tobes added a commit that referenced this pull request May 6, 2013
@amercader
Copy link
Member

Merged into 2.0 and 1.8.1

@amercader amercader closed this May 6, 2013
@smotornyuk smotornyuk deleted the 808-unicode-url-error branch December 19, 2018 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants