Skip to content

Commit

Permalink
added a unicode based test, and fixed the redirect code to pass
Browse files Browse the repository at this point in the history
  • Loading branch information
bengillies committed Mar 7, 2011
1 parent de9416e commit 42f71b3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
18 changes: 18 additions & 0 deletions test/test_redirect.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,21 @@ def test_post_redirect_in_body():
assert tiddler.title == 'HelloWorld'
assert tiddler.text == 'Hi There'
assert tiddler.fields.get('redirect', None) == None

def test_unicode_redirect():
"""
redirect to a unicode url
"""
store = setup_store()
setup_web()
http = httplib2.Http()

#add a tiddler specifying a redirect that is unicode
http.follow_redirects = False
response = http.request('http://test_domain:8001/recipes/foobar/tiddlers?redirect=/bags/foo/tiddlers/%E2%82%AC%E2%88%91%C2%AA%C2%A8~%C3%9F',
method='POST',
headers={'Content-type': 'application/x-www-form-urlencoded'},
body='title=HelloWorld&text=Hi%20There')[0]

#check that we get a 303 response
assert response.status == 303
4 changes: 2 additions & 2 deletions tiddlywebplugins/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from tiddlyweb.web.handler.tiddler import put
from tiddlyweb.web.http import HTTP400
from tiddlyweb.serializer import Serializer, TiddlerFormatError
from tiddlyweb.serializations import SerializationInterface
from tiddlyweb.serializations import SerializationInterface
from tiddlyweb.web import util as web
from cgi import FieldStorage
from socket import timeout
Expand Down Expand Up @@ -89,7 +89,7 @@ def dummy_start_response(response_code, *args):
if not response_code.startswith('204'):
start_response(response_code, *args)
elif redirect:
response = [('Location', str(redirect[0]))]
response = [('Location', redirect[0].encode('UTF-8', 'replace'))]
start_response('303 See Other', response)
else:
start_response(response_code, *args)
Expand Down

0 comments on commit 42f71b3

Please sign in to comment.