Skip to content

Commit

Permalink
Merge pull request #11072 from jeabakker/exception-handling
Browse files Browse the repository at this point in the history
security(exceptions): show admins less on exceptions
  • Loading branch information
jdalsem committed Aug 3, 2017
2 parents f2d74bd + ec1ac7d commit a42b725
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ php:
# This helps builds go quicker on Travis since it enables caching of dependencies
# http://docs.travis-ci.com/user/workers/container-based-infrastructure/
sudo: false

dist: precise

branches:
except:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/**
* Elgg exception (failsafe mode)
* Displays a single exception
*
* @package Elgg
* @subpackage Core
*
* @uses $vars['object'] An exception
*/

$exception = $vars['object'];
/* @var \Exception $exception */
?>

<p class="elgg-messages-exception">
<span title="<?= get_class($exception); ?>">
<?= nl2br($exception->getMessage()); ?>
<br /><br />
Log at time <?= $vars['ts']; ?> may have more data.
</span>
</p>

<?php
if ($exception instanceof \DatabaseException) {
// likely contains credentials
return;
}
?>

<p class="elgg-messages-exception">
<?= nl2br(htmlentities(print_r($exception, true), ENT_QUOTES, 'UTF-8')); ?>
</p>
20 changes: 6 additions & 14 deletions views/failsafe/messages/exceptions/admin_exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* Elgg exception (failsafe mode)
* Displays a single exception
*
* @tip Enable "developers" to give admins a stacktrace view.
*
* @package Elgg
* @subpackage Core
*
Expand All @@ -12,19 +14,9 @@
?>

<p class="elgg-messages-exception">
<span title="<?php echo get_class($vars['object']); ?>">
<?php

echo nl2br($vars['object']->getMessage());

?>
<span title="Unrecoverable Error">
<?php echo elgg_echo('exception:contact_admin'); ?>
<br /><br />
Exception at time <?php echo $vars['ts']; ?>.
</span>
</p>

<p class="elgg-messages-exception">
<?php

echo nl2br(htmlentities(print_r($vars['object'], true), ENT_QUOTES, 'UTF-8'));

?>
</p>

0 comments on commit a42b725

Please sign in to comment.