Commit f032d6f1 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Display a message and don't save config when htmlpurifier fails on a newly configured block.

(Will be useful for bug #547773 if we want to throw exceptions from purifier before timing out)
Signed-off-by: default avatarRichard Mansfield <>
parent c5c0cf7b
......@@ -488,12 +488,21 @@ class BlockInstance {
$this->set('title', $title);
try {
$rendered = $this->render_editing(false, false, $form->submitted_by_js());
catch (HTMLPurifier_Exception $e) {
$message = get_string('blockconfigurationrenderingerror', 'view') . ' ' . $e->getMessage();
$form->reply(PIEFORM_ERR, array('message' => $message));
$result = array(
'error' => false,
'message' => get_string('blockinstanceconfiguredsuccessfully', 'view'),
'data' => $this->render_editing(false, false, $form->submitted_by_js()),
'data' => $rendered,
'blockid' => $this->get('id'),
'viewid' => $this->get('view'),
......@@ -1188,5 +1188,9 @@ function blockConfigError(form, data) {
eval(data.formelementerror + '(form, data)');
else if ($('instconf') && data.message && viewManager) {
formError(form, data);
......@@ -191,6 +191,7 @@ $string['err.changetheme'] = 'Could not update theme';
$string['confirmdeleteblockinstance'] = 'Are you sure you wish to delete this block?';
$string['blockinstanceconfiguredsuccessfully'] = 'Block configured successfully';
$string['blockconfigurationrenderingerror'] = 'Configuration failed because the block could not be rendered.';
$string['blocksintructionnoajax'] = 'Select a block and choose where to add it to your View. You can position a block using the arrow buttons in its titlebar';
$string['blocksinstructionajax'] = 'This area shows a preview of what your View will look like.<br>Drag blocks below this line to add them to your View layout. You can drag blocks around your View layout to position them.';
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