open-humans icon indicating copy to clipboard operation
open-humans copied to clipboard

Unicode error in page URL

Open madprime opened this issue 7 years ago • 2 comments

Site produces an error rather than 404 when a URL containing unicode is attempted. URLs are converted into identifiers for CSS purposes, and this seems to be the source of the error.

(Low priority, since it only occurs when individuals -- possibly bots -- are trying incorrect URLs.)

UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-7: ordinal not in range(128)
(17 additional frame(s) were not displayed)
...
  File "open_humans/views.py", line 434, in server_error
    response = render(request, '500.html')
  File "open_humans/templatetags/utilities.py", line 192, in page_body_id
    return 'page-{}'.format(path)

madprime avatar May 16 '17 14:05 madprime

What happens when project names include unicode characters? For TwArχiv I tried changing the name on OH to 'TwArχiv' but as it lead to strange URLs I chose to stick to the twitter-archive-analyzer. Just wonder whether this could lead to problems.

gedankenstuecke avatar Dec 28 '17 19:12 gedankenstuecke

@gedankenstuecke re: "TwArχiv" I think the culprit is the AutoSlugField; one fix would be to pass in your own slugify method that didn't mangle the URL

In [1]: from autoslug.settings import slugify

In [2]: slugify('TwArχiv')
Out[2]: u'twariv'

beaugunderson avatar Dec 28 '17 21:12 beaugunderson