Skip to content

Commit

Permalink
Fix encoding issue with web.py JSON decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
deanishe committed May 11, 2014
1 parent 3e76a9f commit 49acf86
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
Binary file modified alfred-workflow.zip
Binary file not shown.
8 changes: 8 additions & 0 deletions tests/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ def test_file_upload_without_form_data(self):
bindata = b64decode(bindata[len(preamble):])
self.assertEqual(bindata, open(self.test_file, 'rb').read())

def test_json_encoding(self):
"""JSON decoded correctly"""
url = 'https://suggestqueries.google.com/complete/search?client=firefox&q=münchen'
r = web.get(url)
self.assertEqual(r.status_code, 200)
data = r.json()
self.assertEqual(data[0], 'münchen')


if __name__ == '__main__': # pragma: no cover
unittest.main()
2 changes: 1 addition & 1 deletion workflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def main(wf):
"""

__version__ = '1.4.1'
__version__ = '1.4.2'

from .workflow import Workflow, PasswordNotFound, KeychainError
from .workflow import (ICON_ERROR, ICON_WARNING, ICON_NOTE, ICON_INFO,
Expand Down
2 changes: 1 addition & 1 deletion workflow/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def json(self):
"""

return json.loads(self.content)
return json.loads(self.content, self.encoding or 'utf-8')

@property
def text(self):
Expand Down

0 comments on commit 49acf86

Please sign in to comment.