Skip to content

Commit

Permalink
Bugfix: Exception pages did not report their contents as text/html, b…
Browse files Browse the repository at this point in the history
…ut used text/plain instead, or didnt report Content-Type at all.
  • Loading branch information
janjaapdriessen committed Feb 7, 2018
1 parent e7370c1 commit 205c650
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Changelog
3.0.3 (unreleased)
------------------

- Nothing changed yet.

- Bugfix: Exception pages did not report their contents as text/html, but used
text/plain instead, or didnt report Content-Type at all.

3.0.2 (2018-01-17)
------------------
Expand Down
2 changes: 2 additions & 0 deletions src/grokcore/layout/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def __call__(self):
# A redirect was triggered somewhere in update(). Don't
# continue rendering the template or doing anything else.
return
self.request.response.setHeader(
'Content-Type', 'text/html;charset=utf-8')
return self.layout(self)

def default_namespace(self):
Expand Down
6 changes: 6 additions & 0 deletions src/grokcore/layout/tests/models/errorviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<div class="layout">A system error occurred.</div>
</body>
</html>
>>> print(view.request.response.getHeader('Content-Type'))
text/html;charset=utf-8
>>> from zope.security.interfaces import Unauthorized
>>> class MockPrincipal(object):
Expand All @@ -26,6 +28,8 @@
<div class="layout">Access to the requested resource is forbidden.</div>
</body>
</html>
>>> print(errorpage.request.response.getHeader('Content-Type'))
text/html;charset=utf-8
>>> from zope.publisher.interfaces import NotFound
>>> request = TestRequest()
Expand All @@ -37,6 +41,8 @@
<div class="layout">The requested resource can not be found.</div>
</body>
</html>
>>> print(errorpage.request.response.getHeader('Content-Type'))
text/html;charset=utf-8
"""
import grokcore.component as grok
Expand Down

0 comments on commit 205c650

Please sign in to comment.