[Testbot] Plone 5.0 - Python 2.7 - Build # 2576 - Improvement! - 9 failure(s)
jenkins at plone.org
jenkins at plone.org
Tue Jun 17 11:49:20 UTC 2014
-------------------------------------------------------------------------------
Plone 5.0 - Python 2.7 - Build # 2576 - Aborted!
-------------------------------------------------------------------------------
http://jenkins.plone.org/job/plone-5.0-python-2.7/2576/
-------------------------------------------------------------------------------
CHANGES
-------------------------------------------------------------------------------
Repository: plone.formwidget.namedfile
Branch: refs/heads/master
Date: 2014-06-16T16:47:17+02:00
Author: Lukas Graf (lukasgraf) <lukas.graf at 4teamwork.ch>
Commit: https://github.com/plone/plone.formwidget.namedfile/commit/5f789706563560ec7ae3f67d42e7daa9d6c2322f
Ignore contentType sent by browser for file uploads.
Files changed:
M docs/HISTORY.txt
M plone/formwidget/namedfile/converter.py
M plone/formwidget/namedfile/widget.txt
M setup.py
diff --git a/docs/HISTORY.txt b/docs/HISTORY.txt
index 3173b24..10975ba 100644
--- a/docs/HISTORY.txt
+++ b/docs/HISTORY.txt
@@ -1,11 +1,12 @@
Changelog
=========
-1.0.11 (unreleased)
--------------------
-
-- Nothing changed yet.
+1.1 (unreleased)
+----------------
+- Ignore contentType sent by browser for file uploads.
+ See https://github.com/plone/plone.formwidget.namedfile/issues/9
+ [lgraf]
1.0.10 (2014-05-26)
-------------------
diff --git a/plone/formwidget/namedfile/converter.py b/plone/formwidget/namedfile/converter.py
index 814dd89..f96660a 100644
--- a/plone/formwidget/namedfile/converter.py
+++ b/plone/formwidget/namedfile/converter.py
@@ -26,22 +26,17 @@ def toFieldValue(self, value):
return value
elif isinstance(value, FileUpload):
- headers = value.headers
filename = safe_basename(value.filename)
if filename is not None and not isinstance(filename, unicode):
# Work-around for
# https://bugs.launchpad.net/zope2/+bug/499696
filename = filename.decode('utf-8')
-
- contentType = 'application/octet-stream'
- if headers:
- contentType = headers.get('Content-Type', contentType)
-
+
value.seek(0)
data = value.read()
if data or filename:
- return self.field._type(data=data, contentType=contentType, filename=filename)
+ return self.field._type(data=data, filename=filename)
else:
return self.field.missing_value
diff --git a/plone/formwidget/namedfile/widget.txt b/plone/formwidget/namedfile/widget.txt
index 5a46aac..e555554 100644
--- a/plone/formwidget/namedfile/widget.txt
+++ b/plone/formwidget/namedfile/widget.txt
@@ -512,8 +512,11 @@ A data string is converted to the appropriate type:
>>> image_converter.toFieldValue('random data')
<plone.namedfile.file.NamedImage object at ...>
-A FileUpload object is converted to the appropriate type, preserving filename
-and content type, and possibly handling international characters in filenames.
+A FileUpload object is converted to the appropriate type, preserving filename,
+and possibly handling international characters in filenames.
+The content type sent by the browser will be ignored because it's unreliable
+- it's left to the implementation of the file field to determine the proper
+content type.
>>> myfile = cStringIO.StringIO('File upload contents.')
>>> # \xc3\xb8 is UTF-8 for a small letter o with slash
@@ -524,8 +527,11 @@ and content type, and possibly handling international characters in filenames.
'File upload contents.'
>>> file_obj.filename
u'rand\xf8m.txt'
- >>> file_obj.contentType
- 'text/x-dummy'
+
+Content type from headers sent by browser should be ignored:
+
+ >>> file_obj.contentType != 'text/x-dummy'
+ True
>>> myfile = cStringIO.StringIO('Random image content.')
>>> aFieldStorage = FieldStorageStub(myfile, filename='random.png', headers={'Content-Type': 'image/x-dummy'})
@@ -534,8 +540,9 @@ and content type, and possibly handling international characters in filenames.
'Random image content.'
>>> image_obj.filename
u'random.png'
- >>> image_obj.contentType
- 'image/x-dummy'
+ >>> image_obj.contentType != 'image/x-dummy'
+ True
+
However, a zero-length, unnamed FileUpload results in the field's missing_value
being returned.
diff --git a/setup.py b/setup.py
index a2b7b25..821f98f 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
import os
-version = '1.0.11.dev0'
+version = '1.1.dev0'
setup(name='plone.formwidget.namedfile',
version=version,
Repository: plone.formwidget.namedfile
Branch: refs/heads/master
Date: 2014-06-16T23:12:41+02:00
Author: Jens W. Klein (jensens) <jens at bluedynamics.com>
Commit: https://github.com/plone/plone.formwidget.namedfile/commit/2045a952b6eb60a889392dd6f8219d3a065fba5f
Merge pull request #9 from plone/lg-ignore-browser-contenttype
Ignore contentType sent by browsers for file uploads
Files changed:
M docs/HISTORY.txt
M plone/formwidget/namedfile/converter.py
M plone/formwidget/namedfile/widget.txt
M setup.py
diff --git a/docs/HISTORY.txt b/docs/HISTORY.txt
index 3173b24..10975ba 100644
--- a/docs/HISTORY.txt
+++ b/docs/HISTORY.txt
@@ -1,11 +1,12 @@
Changelog
=========
-1.0.11 (unreleased)
--------------------
-
-- Nothing changed yet.
+1.1 (unreleased)
+----------------
+- Ignore contentType sent by browser for file uploads.
+ See https://github.com/plone/plone.formwidget.namedfile/issues/9
+ [lgraf]
1.0.10 (2014-05-26)
-------------------
diff --git a/plone/formwidget/namedfile/converter.py b/plone/formwidget/namedfile/converter.py
index 814dd89..f96660a 100644
--- a/plone/formwidget/namedfile/converter.py
+++ b/plone/formwidget/namedfile/converter.py
@@ -26,22 +26,17 @@ def toFieldValue(self, value):
return value
elif isinstance(value, FileUpload):
- headers = value.headers
filename = safe_basename(value.filename)
if filename is not None and not isinstance(filename, unicode):
# Work-around for
# https://bugs.launchpad.net/zope2/+bug/499696
filename = filename.decode('utf-8')
-
- contentType = 'application/octet-stream'
- if headers:
- contentType = headers.get('Content-Type', contentType)
-
+
value.seek(0)
data = value.read()
if data or filename:
- return self.field._type(data=data, contentType=contentType, filename=filename)
+ return self.field._type(data=data, filename=filename)
else:
return self.field.missing_value
diff --git a/plone/formwidget/namedfile/widget.txt b/plone/formwidget/namedfile/widget.txt
index 5a46aac..e555554 100644
--- a/plone/formwidget/namedfile/widget.txt
+++ b/plone/formwidget/namedfile/widget.txt
@@ -512,8 +512,11 @@ A data string is converted to the appropriate type:
>>> image_converter.toFieldValue('random data')
<plone.namedfile.file.NamedImage object at ...>
-A FileUpload object is converted to the appropriate type, preserving filename
-and content type, and possibly handling international characters in filenames.
+A FileUpload object is converted to the appropriate type, preserving filename,
+and possibly handling international characters in filenames.
+The content type sent by the browser will be ignored because it's unreliable
+- it's left to the implementation of the file field to determine the proper
+content type.
>>> myfile = cStringIO.StringIO('File upload contents.')
>>> # \xc3\xb8 is UTF-8 for a small letter o with slash
@@ -524,8 +527,11 @@ and content type, and possibly handling international characters in filenames.
'File upload contents.'
>>> file_obj.filename
u'rand\xf8m.txt'
- >>> file_obj.contentType
- 'text/x-dummy'
+
+Content type from headers sent by browser should be ignored:
+
+ >>> file_obj.contentType != 'text/x-dummy'
+ True
>>> myfile = cStringIO.StringIO('Random image content.')
>>> aFieldStorage = FieldStorageStub(myfile, filename='random.png', headers={'Content-Type': 'image/x-dummy'})
@@ -534,8 +540,9 @@ and content type, and possibly handling international characters in filenames.
'Random image content.'
>>> image_obj.filename
u'random.png'
- >>> image_obj.contentType
- 'image/x-dummy'
+ >>> image_obj.contentType != 'image/x-dummy'
+ True
+
However, a zero-length, unnamed FileUpload results in the field's missing_value
being returned.
diff --git a/setup.py b/setup.py
index a2b7b25..821f98f 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
import os
-version = '1.0.11.dev0'
+version = '1.1.dev0'
setup(name='plone.formwidget.namedfile',
version=version,
-------------------------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CHANGES.log
Type: application/octet-stream
Size: 8571 bytes
Desc: not available
URL: <http://lists.plone.org/pipermail/plone-testbot/attachments/20140617/33661adb/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: build.log
Type: application/octet-stream
Size: 219082 bytes
Desc: not available
URL: <http://lists.plone.org/pipermail/plone-testbot/attachments/20140617/33661adb/attachment-0003.obj>
More information about the Testbot
mailing list