Skip to content

Commit

Permalink
Issue CollaboraOnline#56: Don't disclose exception message to visitor.
Browse files Browse the repository at this point in the history
  • Loading branch information
donquixote committed Nov 21, 2024
1 parent 18482de commit b7c3318
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/Controller/ViewerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Drupal\collabora_online\Exception\CollaboraNotAvailableException;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Render\RendererInterface;
use Drupal\Core\Utility\Error;
use Drupal\media\Entity\Media;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand Down Expand Up @@ -62,15 +63,12 @@ public function editor(Media $media, Request $request, $edit = FALSE) {
$wopi_client_url = $this->discovery->getWopiClientURL();
}
catch (CollaboraNotAvailableException $e) {
$error_msg = $this->t('The Collabora Online server is not available: @message', [
'@message' => $e->getCode() . ': ' . $e->getMessage(),
]);
$error_msg = $this->t('Viewer error: @message', [
'@message' => $error_msg,
]);
$this->getLogger('cool')->error($error_msg);
$this->getLogger('cool')->warning(
"Collabora Online is not available.<br>\n" . Error::DEFAULT_ERROR_MESSAGE,
Error::decodeException($e) + [],
);
return new Response(
$error_msg,
$this->t('The Collabora Online editor/viewer is not available.'),
Response::HTTP_BAD_REQUEST,
['content-type' => 'text/plain'],
);
Expand Down

0 comments on commit b7c3318

Please sign in to comment.