mirror of
https://github.com/friendica/friendica
synced 2025-04-19 07:10:11 +00:00
Merge pull request #9621 from MrPetovan/bug/9611-bbcode-convert-html-purify
Add HTML Purify to BBCode::convert
This commit is contained in:
commit
f9994548c1
9 changed files with 181 additions and 131 deletions
|
@ -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'),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue