From a382798999c2b0ab6667d8d7c8e187b7b4c5b5b0 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 4 Dec 2020 07:28:18 -0500 Subject: [PATCH] Add some more result panels to Babel --- src/Module/Debug/Babel.php | 26 +++++++++++++++++++++++++- view/templates/babel.tpl | 4 +--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/Module/Debug/Babel.php b/src/Module/Debug/Babel.php index 5b89c5301..e33f03214 100644 --- a/src/Module/Debug/Babel.php +++ b/src/Module/Debug/Babel.php @@ -49,7 +49,7 @@ class Babel extends BaseModule if (!empty($_REQUEST['text'])) { switch (($_REQUEST['type'] ?? '') ?: 'bbcode') { case 'bbcode': - $bbcode = trim($_REQUEST['text']); + $bbcode = $_REQUEST['text']; $results[] = [ 'title' => DI::l10n()->t('Source input'), 'content' => visible_whitespace($bbcode) @@ -67,6 +67,11 @@ class Babel extends BaseModule 'content' => visible_whitespace($html) ]; + $results[] = [ + 'title' => DI::l10n()->t('BBCode::convert (hex)'), + 'content' => visible_whitespace(bin2hex($html)), + ]; + $results[] = [ 'title' => DI::l10n()->t('BBCode::convert'), 'content' => $html @@ -178,6 +183,25 @@ class Babel extends BaseModule 'content' => $html ]; + $config = \HTMLPurifier_Config::createDefault(); + $HTMLPurifier = new \HTMLPurifier($config); + $purified = $HTMLPurifier->purify($html); + + $results[] = [ + 'title' => DI::l10n()->t('HTML Purified (raw)'), + 'content' => visible_whitespace($purified), + ]; + + $results[] = [ + 'title' => DI::l10n()->t('HTML Purified (hex)'), + 'content' => visible_whitespace(bin2hex($purified)), + ]; + + $results[] = [ + 'title' => DI::l10n()->t('HTML Purified'), + 'content' => $purified, + ]; + $bbcode = Text\HTML::toBBCode($html); $results[] = [ 'title' => DI::l10n()->t('HTML::toBBCode'), diff --git a/view/templates/babel.tpl b/view/templates/babel.tpl index 57d17fea9..9b5a3d62a 100644 --- a/view/templates/babel.tpl +++ b/view/templates/babel.tpl @@ -24,9 +24,7 @@

{{$result.title}}

-
- {{$result.content nofilter}} -
+
{{$result.content nofilter}}
{{/foreach}}