Skip to content

Commit

Permalink
announcements: Transform markdown markup
Browse files Browse the repository at this point in the history
  • Loading branch information
nilmerg committed Jun 25, 2019
1 parent 6c54dc8 commit c6a61f9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
5 changes: 2 additions & 3 deletions library/Icinga/Web/Widget/Announcements.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Icinga\Forms\Announcement\AcknowledgeAnnouncementForm;
use Icinga\Web\Announcement\AnnouncementCookie;
use Icinga\Web\Announcement\AnnouncementIniRepository;
use Icinga\Web\Helper\HtmlPurifier;
use Icinga\Web\Helper\Markdown;

/**
* Render announcements
Expand Down Expand Up @@ -36,13 +36,12 @@ public function render()
$announcements = $repo->findActive();
$announcements->applyFilter($acked);
if ($announcements->hasResult()) {
$purifier = new HtmlPurifier(array('HTML.Allowed' => 'b,a[href|target],i,*[class]'));
$html = '<ul role="alert" id="announcements">';
foreach ($announcements as $announcement) {
$ackForm = new AcknowledgeAnnouncementForm();
$ackForm->populate(array('hash' => $announcement->hash));
$html .= '<li><div>'
. $purifier->purify($announcement->message)
. Markdown::text($announcement->message)
. '</div>'
. $ackForm
. '</li>';
Expand Down
12 changes: 2 additions & 10 deletions library/Icinga/Web/Widget/ApplicationStateMessages.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Icinga\Authentication\Auth;
use Icinga\Forms\AcknowledgeApplicationStateMessageForm;
use Icinga\Web\ApplicationStateCookie;
use Icinga\Web\Helper\HtmlPurifier;
use Icinga\Web\Helper\Markdown;

/**
* Render application state messages
Expand All @@ -27,12 +27,6 @@ protected function getMessages()
return $active;
}


protected function getPurifier()
{
return new HtmlPurifier(['HTML.Allowed' => 'b,a[href|target],i,*[class]']);
}

public function render()
{
$enabled = Auth::getInstance()
Expand All @@ -55,8 +49,6 @@ public function render()
return '<div style="display: none;"></div>';
}

$purifier = $this->getPurifier();

$html = '<div>';

reset($active);
Expand All @@ -69,7 +61,7 @@ public function render()
$ackForm = new AcknowledgeApplicationStateMessageForm();
$ackForm->populate(['id' => $id]);

$html .= $purifier->purify($message) . $ackForm;
$html .= Markdown::text($message) . $ackForm;

$html .= '</div>';

Expand Down

0 comments on commit c6a61f9

Please sign in to comment.