Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
slapos
Commits
3091dbb2
Commit
3091dbb2
authored
Nov 22, 2022
by
Jérome Perrin
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5:
🚧
try zope patch
🚧
parent
2312ed83
Pipeline
#25161
failed with stage
in 0 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
1 deletion
+95
-1
component/egg-patch/Zope2/0001-HTTPResponse-default-content-type-to-text-plain.patch
...001-HTTPResponse-default-content-type-to-text-plain.patch
+92
-0
stack/erp5/buildout.cfg
stack/erp5/buildout.cfg
+3
-1
No files found.
component/egg-patch/Zope2/0001-HTTPResponse-default-content-type-to-text-plain.patch
0 → 100644
View file @
3091dbb2
From 346f895cd6c95346bcd8668fd7e7a90e9547e789 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Tue, 22 Nov 2022 17:33:02 +0900
Subject: [PATCH] HTTPResponse: default content type to text/plain
---
src/ZPublisher/HTTPResponse.py | 11 +++++------
src/ZPublisher/tests/testHTTPResponse.py | 8 ++++----
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/src/ZPublisher/HTTPResponse.py b/src/ZPublisher/HTTPResponse.py
index 002737d15..b9337201c 100644
--- a/src/ZPublisher/HTTPResponse.py
+++ b/src/ZPublisher/HTTPResponse.py
@@ -462,9 +462,13 @@
class HTTPResponse(BaseResponse):
if isinstance(body, tuple) and len(body) == 2:
title, body = body
+ content_type = self.headers.get('content-type')
+
if not isinstance(body, str):
if hasattr(body,'asHTML'):
body = body.asHTML()
+ if content_type is None:
+ content_type = 'text/html'
if isinstance(body, unicode):
body = self._encode_unicode(body)
@@ -491,8 +495,6 @@
class HTTPResponse(BaseResponse):
self.body = body
- content_type = self.headers.get('content-type')
-
# Some browsers interpret certain characters in Latin 1 as html
# special characters. These cannot be removed by html_quote,
# because this is not the case for all encodings.
@@ -503,10 +505,7 @@
class HTTPResponse(BaseResponse):
self.body = body
if content_type is None:
- if self.isHTML(self.body):
- content_type = 'text/html; charset=%s' % default_encoding
- else:
- content_type = 'text/plain; charset=%s' % default_encoding
+ content_type = 'text/plain; charset=%s' % default_encoding
self.setHeader('content-type', content_type)
else:
if (content_type.startswith('text/') and
diff --git a/src/ZPublisher/tests/testHTTPResponse.py b/src/ZPublisher/tests/testHTTPResponse.py
index 42946973a..9bbc932af 100644
--- a/src/ZPublisher/tests/testHTTPResponse.py
+++ b/src/ZPublisher/tests/testHTTPResponse.py
@@ -584,7 +584,7 @@
class HTTPResponseTests(unittest.TestCase):
self.assertTrue(result)
self.assertEqual(response.body, EXPECTED)
self.assertEqual(response.getHeader('Content-Type'),
- 'text/html; charset=iso-8859-15')
+ 'text/plain; charset=iso-8859-15')
self.assertEqual(response.getHeader('Content-Length'),
str(len(EXPECTED)))
@@ -598,7 +598,7 @@
class HTTPResponseTests(unittest.TestCase):
self.assertTrue('TITLE' in response.body)
self.assertTrue('BODY' in response.body)
self.assertEqual(response.getHeader('Content-Type'),
- 'text/html; charset=iso-8859-15')
+ 'text/plain; charset=iso-8859-15')
def test_setBody_string_not_HTML(self):
response = self._makeOne()
@@ -616,7 +616,7 @@
class HTTPResponseTests(unittest.TestCase):
self.assertTrue(result)
self.assertEqual(response.body, HTML)
self.assertEqual(response.getHeader('Content-Type'),
- 'text/html; charset=iso-8859-15')
+ 'text/plain; charset=iso-8859-15')
self.assertEqual(response.getHeader('Content-Length'), str(len(HTML)))
def test_setBody_object_with_asHTML(self):
@@ -640,7 +640,7 @@
class HTTPResponseTests(unittest.TestCase):
self.assertTrue(result)
self.assertEqual(response.body, ENCODED)
self.assertEqual(response.getHeader('Content-Type'),
- 'text/html; charset=iso-8859-15')
+ 'text/plain; charset=iso-8859-15')
self.assertEqual(response.getHeader('Content-Length'),
str(len(ENCODED)))
--
2.37.0
stack/erp5/buildout.cfg
View file @
3091dbb2
...
@@ -696,6 +696,8 @@ Acquisition-patches = ${:_profile_base_location_}/../../component/egg-patch/Acqu
...
@@ -696,6 +696,8 @@ Acquisition-patches = ${:_profile_base_location_}/../../component/egg-patch/Acqu
Acquisition-patch-options = -p1
Acquisition-patch-options = -p1
python-magic-patches = ${:_profile_base_location_}/../../component/egg-patch/python_magic/magic.patch#de0839bffac17801e39b60873a6c2068
python-magic-patches = ${:_profile_base_location_}/../../component/egg-patch/python_magic/magic.patch#de0839bffac17801e39b60873a6c2068
python-magic-patch-options = -p1
python-magic-patch-options = -p1
Zope2-patches = ${:_profile_base_location_}/../../component/egg-patch/Zope2/0001-HTTPResponse-default-content-type-to-text-plain.patch#7d6a62aedc7756a053004521fbf6d644
Zope2-patch-options = -p1
# neoppod installs bin/coverage so we inject erp5 plugin here so that coverage script can use it in report
# neoppod installs bin/coverage so we inject erp5 plugin here so that coverage script can use it in report
...
@@ -739,7 +741,7 @@ PyPDF2 = 1.26.0+SlapOSPatched001
...
@@ -739,7 +741,7 @@ PyPDF2 = 1.26.0+SlapOSPatched001
pylint = 1.4.4+SlapOSPatched002
pylint = 1.4.4+SlapOSPatched002
# astroid 1.4.1 breaks testDynamicClassGeneration
# astroid 1.4.1 breaks testDynamicClassGeneration
astroid = 1.3.8+SlapOSPatched001
astroid = 1.3.8+SlapOSPatched001
Zope2 = 2.13.30+SlapOSPatched001
# use newer version than specified in ZTK
# use newer version than specified in ZTK
PasteDeploy = 1.5.2
PasteDeploy = 1.5.2
argparse = 1.4.0
argparse = 1.4.0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment