Skip to content

Commit

Permalink
Merge pull request #78 from collective/unicode_filename_save
Browse files Browse the repository at this point in the history
Fix saver action with non ASCII filename uploads #77
  • Loading branch information
agitator committed Jul 12, 2017
2 parents d1495d4 + 0afe86e commit 5eee1b0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.rst
Expand Up @@ -17,6 +17,8 @@ Bug fixes:
- In the schema editor for fields, Fix the URL to ACE library according to the modeleditor in plone.app.dexterity.
[thet]

- Fix saver action with non ASCII filename uploads #77
[tomgross]

2.0.0b1 (2017-06-14)
--------------------
Expand Down
2 changes: 1 addition & 1 deletion src/collective/easyform/actions.py
Expand Up @@ -622,7 +622,7 @@ def getSavedFormInputForEdit(self, header=False, delimiter=','):
def get_data(row, i):
data = row.get(i, '')
if self._is_file_data(data):
return data.filename
data = data.filename
if isinstance(data, unicode):
return data.encode('utf-8')
return data
Expand Down
18 changes: 18 additions & 0 deletions src/collective/easyform/tests/attachment.rst
Expand Up @@ -209,3 +209,21 @@ Check saved data::
>>> browser.getControl("Download").click()


Test file uploads with non ASCII characters in the title

>>> browser.open(portal_url + '/attachmentform')
>>> browser.getControl('Your E-Mail Address').value = 'test@example.com'
>>> browser.getControl('Subject').value = u'München'.encode('latin-1')
>>> browser.getControl('Comments').value = 'PFG rocks!'
>>> browser.getControl(name='form.widgets.attachment').add_file(cStringIO.StringIO('file contents'), 'text/plain', u'Zürich.txt'.encode('latin-1'))
>>> browser.getControl('Submit').click()
<sent mail from ...to ['mdummy@address.com']>
>>> 'Thanks for your input.' in browser.contents
True
>>> from collective.easyform.api import get_actions
>>> saver = get_actions(layer['portal']['attachmentform'])['saver']
>>> print(saver.getSavedFormInputForEdit())
test@example.com,München,PFG rocks!,Zürich.txt
<BLANKLINE>


0 comments on commit 5eee1b0

Please sign in to comment.