Commit 636de5ba authored by Arnaud Fontaine's avatar Arnaud Fontaine

zope5: Since Zope 5.8.1 CONTENT_TYPE HTTP header must be specified for PUT request.

Despite RFC 4918 stating that Content-Type *SHOULD* be provided, since the
following commit no CONTENT_TYPE means application/x-www-form-urlencoded thus
processing the request as a form and not a binary file (with cgi.FieldStorage,
it was text/plain and all the form-processing logic was skipped):
  commit 5b324f6c461f5ea1cc069739b6c32a1a5ff59df9
  Date:   Thu Jan 19 07:15:18 2023 +0100
    replace `cgi.FieldStorage` by `multipart` (#1094)
    * interpret a missing `CONTENT_TYPE` as `application/x-www-form-urlencoded`

This raises the following exception:
  Traceback (most recent call last):
    File "erp5://portal_components/test.erp5.testWebDavSupport", line 232, in test_PROPFIND_on_document
      response = self.publish(
    File "/opt/slapgrid/3f9add9291086dee302fc478df4b3130/parts/erp5/product/ERP5Type/tests/ERP5TypeTestCase.py", line 793, in publish
      return super(ERP5TypeTestCaseMixin, self).publish(
    File "/opt/slapgrid/3f9add9291086dee302fc478df4b3130/eggs/Zope-5.10-py3.9.egg/Testing/ZopeTestCase/functional.py", line 42, in wrapped_func
      return func(*args, **kw)
    File "/opt/slapgrid/3f9add9291086dee302fc478df4b3130/eggs/Zope-5.10-py3.9.egg/Testing/ZopeTestCase/functional.py", line 133, in publish
      wsgi_result = publish(env, start_response)
    File "/opt/slapgrid/3f9add9291086dee302fc478df4b3130/eggs/Zope-5.10-py3.9.egg/ZPublisher/httpexceptions.py", line 30, in __call__
      return self.application(environ, start_response)
    File "/opt/slapgrid/3f9add9291086dee302fc478df4b3130/eggs/Zope-5.10-py3.9.egg/ZPublisher/WSGIPublisher.py", line 391, in publish_module
      response = _publish(request, new_mod_info)
    File "/opt/slapgrid/3f9add9291086dee302fc478df4b3130/parts/erp5/product/ERP5Type/patches/WSGIPublisher.py", line 150, in publish
      return _original_publish(request, module_info)
    File "/opt/slapgrid/3f9add9291086dee302fc478df4b3130/eggs/Zope-5.10-py3.9.egg/ZPublisher/WSGIPublisher.py", line 251, in publish
      request.processInputs()
    File "/opt/slapgrid/3f9add9291086dee302fc478df4b3130/parts/erp5/product/Localizer/patches.py", line 37, in new_processInputs
      HTTPRequest.old_processInputs(self)
    File "/opt/slapgrid/3f9add9291086dee302fc478df4b3130/eggs/Zope-5.10-py3.9.egg/ZPublisher/HTTPRequest.py", line 544, in processInputs
      key = item.name.encode("latin-1").decode(
  UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe3 in position 10: invalid continuation byte
parent 614e6ac0
......@@ -86,6 +86,7 @@ class TestWebDavSupport(ERP5TypeTestCase):
response = self.publish(person.getPath() + '/erp5_logo.png',
request_method='PUT',
stdin=file_object,
env={"CONTENT_TYPE": 'image/png'},
basic=self.authentication)
self.assertEqual(response.getStatus(), httplib.CREATED)
image = person['erp5_logo.png']
......@@ -105,6 +106,8 @@ class TestWebDavSupport(ERP5TypeTestCase):
response = self.publish('%s/%s' % (path, filename),
request_method='PUT',
stdin=file_object,
env={"CONTENT_TYPE":
'application/vnd.oasis.opendocument.presentation'},
basic=self.authentication)
self.assertEqual(response.getStatus(), httplib.CREATED)
......@@ -127,6 +130,8 @@ class TestWebDavSupport(ERP5TypeTestCase):
response = self.publish('%s/%s' % (path, filename),
request_method='PUT',
stdin=file_object,
env={"CONTENT_TYPE":
'application/vnd.oasis.opendocument.presentation'},
basic=self.authentication)
self.assertEqual(response.getStatus(), httplib.CREATED)
......@@ -198,6 +203,8 @@ class TestWebDavSupport(ERP5TypeTestCase):
response = self.publish('%s/%s' % (path, filename),
request_method='PUT',
stdin=file_object,
env={"CONTENT_TYPE":
'application/vnd.oasis.opendocument.presentation'},
basic=self.authentication)
# Convert to base format and run conversion into utf-8
self.tic()
......@@ -225,6 +232,8 @@ class TestWebDavSupport(ERP5TypeTestCase):
response = self.publish('%s/%s' % (path, filename),
request_method='PUT',
stdin=file_object,
env={"CONTENT_TYPE":
'application/vnd.oasis.opendocument.presentation'},
basic=self.authentication)
document_module = self.getDocumentModule()
document = document_module[filename]
......@@ -263,6 +272,8 @@ class TestWebDavSupport(ERP5TypeTestCase):
response = self.publish('%s/%s' % (path, filename),
request_method='PUT',
stdin=file_object,
env={"CONTENT_TYPE":
'application/vnd.oasis.opendocument.presentation'},
basic=self.authentication)
document_module = self.getDocumentModule()
document = document_module[filename]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment