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

unicode can dict provided to template can cause errors #1

Closed
cdent opened this issue May 2, 2012 · 1 comment
Closed

unicode can dict provided to template can cause errors #1

cdent opened this issue May 2, 2012 · 1 comment

Comments

@cdent
Copy link
Contributor

cdent commented May 2, 2012

Here's an example:

http://cdent.tiddlyspace.com/bags/cdent-bkm_public/tiddlers/ongoing%20by%20Tim%20Bray%20·%204G%20Performance%20Silliness/revisions/563984

(note the '·' in the uri)

When that revision is not found pretty error barfs with the following traceback (which doesn't get logged well because it is pretty error itself barfing):


[Wed May 02 18:30:30 2012] [error] [client 86.142.249.43] mod_wsgi (pid=23189): Exception occurred processing WSGI script '/home/tiddlyweb/tiddlywebs/tiddlyspace.com/apache.py'.
[Wed May 02 18:30:30 2012] [error] [client 86.142.249.43] Traceback (most recent call last):
[Wed May 02 18:30:30 2012] [error] [client 86.142.249.43]   File "/usr/lib/python2.5/site-packages/tiddlyweb/web/wsgi.py", line 144, in __call__
[Wed May 02 18:30:30 2012] [error] [client 86.142.249.43]     return self.application(environ, start_response)
[Wed May 02 18:30:30 2012] [error] [client 86.142.249.43]   File "/usr/lib/python2.5/site-packages/tiddlyweb/web/wsgi.py", line 236, in __call__
[Wed May 02 18:30:30 2012] [error] [client 86.142.249.43]     return self.application(environ, replacement_start_response)
[Wed May 02 18:30:30 2012] [error] [client 86.142.249.43]   File "/usr/lib/python2.5/site-packages/tiddlywebplugins/cookiedomain.py", line 55, in __call__
[Wed May 02 18:30:30 2012] [error] [client 86.142.249.43]     return self.application(environ, replacement_start_response)
[Wed May 02 18:30:30 2012] [error] [client 86.142.249.43]   File "/usr/lib/python2.5/site-packages/tiddlyweb/web/wsgi.py", line 249, in __call__
[Wed May 02 18:30:30 2012] [error] [client 86.142.249.43]     self.application(environ, start_response))
[Wed May 02 18:30:30 2012] [error] [client 86.142.249.43]   File "/usr/lib/python2.5/site-packages/tiddlywebplugins/tiddlyspace/controlview.py", line 281, in __call__
[Wed May 02 18:30:30 2012] [error] [client 86.142.249.43]     return self.application(environ, replacement_start_response)
[Wed May 02 18:30:30 2012] [error] [client 86.142.249.43]   File "/usr/lib/python2.5/site-packages/tiddlywebplugins/tiddlyspace/repudiator.py", line 23, in __call__
[Wed May 02 18:30:30 2012] [error] [client 86.142.249.43]     wrapper.replacement_start_response)
[Wed May 02 18:30:30 2012] [error] [client 86.142.249.43]   File "/usr/lib/python2.5/site-packages/tiddlywebplugins/prettyerror/exceptor.py", line 58, in __call__
[Wed May 02 18:30:30 2012] [error] [client 86.142.249.43]     return self._send_response(environ, start_response, exc_info, exc)
[Wed May 02 18:30:30 2012] [error] [client 86.142.249.43]   File "/usr/lib/python2.5/site-packages/tiddlywebplugins/prettyerror/exceptor.py", line 92, in _send_response
[Wed May 02 18:30:30 2012] [error] [client 86.142.249.43]     text = format_error_tiddler(environ, status_tiddler, exc)
[Wed May 02 18:30:30 2012] [error] [client 86.142.249.43]   File "/usr/lib/python2.5/site-packages/tiddlywebplugins/prettyerror/exceptor.py", line 173, in format_error_tiddler
[Wed May 02 18:30:30 2012] [error] [client 86.142.249.43]     return template.safe_substitute(**info)
[Wed May 02 18:30:30 2012] [error] [client 86.142.249.43]   File "/usr/lib/python2.5/string.py", line 203, in safe_substitute
[Wed May 02 18:30:30 2012] [error] [client 86.142.249.43]     return self.pattern.sub(convert, self.template)
[Wed May 02 18:30:30 2012] [error] [client 86.142.249.43] UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 35: ordinal not in range(128)

The problem is that the stuff in info has not been properly encoded.

@cdent
Copy link
Contributor Author

cdent commented May 3, 2012

I made an effort to fix this by creating a failing test, but I can only get a failure under apache, so I replicated my potential fix live on tiddlyspace.com and that got the job done.

sigh

@cdent cdent closed this as completed in 160802f May 3, 2012
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

No branches or pull requests

1 participant