settings: remove option to set exception display style (#56802)
gitea-wip/wcs/pipeline/head Build started... Details
gitea/wcs/pipeline/head Something is wrong with the build of this commit Details

This commit is contained in:
Frédéric Péters 2021-09-10 15:45:22 +02:00
parent d38908864f
commit cb94cbdb74
3 changed files with 5 additions and 34 deletions

View File

@ -87,7 +87,9 @@ def test_finish_failed_request():
assert body == '{"err": 1}'
req = get_request()
pub.config.display_exceptions = 'text'
pub.cfg['debug'] = {'debug_mode': True}
pub.write_cfg()
pub.set_config(request=req)
pub._set_request(req)
try:
raise Exception()
@ -96,16 +98,6 @@ def test_finish_failed_request():
assert 'Traceback (most recent call last)' in str(body)
assert '<div class="error-page">' not in str(body)
req = get_request()
pub.config.display_exceptions = 'text-in-html'
pub._set_request(req)
try:
raise Exception()
except Exception:
body = pub.finish_failed_request()
assert 'Traceback (most recent call last)' in str(body)
assert '<div class="error-page">' in str(body)
def test_finish_interrupted_request():
req = HTTPRequest(

View File

@ -73,18 +73,6 @@ class SettingsDirectory(AccessControlled, Directory):
title=_('Email for Tracebacks'),
value=debug_cfg.get('error_email', ''),
)
form.add(
SingleSelectWidget,
'display_exceptions',
title=_('Display Exceptions'),
value=debug_cfg.get('display_exceptions', ''),
options=[
('', _('No display')),
('text', _('Display as Text')),
('text-in-html', _('Display as Text in an HTML error page')),
('html', _('Display as HTML')),
],
)
form.add(CheckboxWidget, 'logger', title=_('Logger'), value=debug_cfg.get('logger', True))
form.add(
CheckboxWidget,
@ -116,6 +104,6 @@ class SettingsDirectory(AccessControlled, Directory):
cfg_submit(
form,
'debug',
('error_email', 'display_exceptions', 'logger', 'debug_mode', 'mail_redirection'),
('error_email', 'logger', 'debug_mode', 'mail_redirection'),
)
return redirect('.')

View File

@ -313,15 +313,6 @@ class QommonPublisher(Publisher):
# DISPLAY_EXCEPTIONS is false, so return the most
# secure (and cryptic) page.
error_page = self._generate_internal_error(request)
elif self.config.display_exceptions == 'html':
# Generate a spiffy HTML display using cgitb
error_page = self._generate_cgitb_error(request, original_response, exc_type, exc_value, tb)
elif self.config.display_exceptions == 'text-in-html':
error_page = template.error_page(
_('The server encountered an internal error and was unable to complete your request.'),
error_title=_('Internal Server Error'),
exception=plain_error_msg,
)
else:
# Generate a plaintext page containing the traceback
request.response.set_header('Content-Type', 'text/plain')
@ -438,7 +429,7 @@ class QommonPublisher(Publisher):
debug_cfg = self.cfg.get('debug', {})
self.logger.error_email = debug_cfg.get('error_email')
self.logger.error_email_from = self.cfg.get('emails', {}).get('from')
self.config.display_exceptions = debug_cfg.get('display_exceptions')
self.config.display_exceptions = debug_cfg.get('debug_mode')
self.config.form_tokens = True
self.config.session_cookie_httponly = True
self.config.allowed_methods = ['GET', 'HEAD', 'POST', 'PUT']