Skip to content

Commit

Permalink
Merge pull request #61 from ArchBlood/enh/allow-symbol-translations
Browse files Browse the repository at this point in the history
Enh: Allow predefined tags, attributes and non-ASCII characters
  • Loading branch information
luke- authored Mar 13, 2024
2 parents 4d1dfa7 + 5afd2e2 commit b8e50f4
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions models/parser/TranslationPurifier.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
<?php


namespace humhub\modules\translation\models\parser;


use yii\helpers\HtmlPurifier;

class TranslationPurifier extends HtmlPurifier
{
/**
* @inheritDoc
*/
public static function configure( $config)
public static function configure($config)
{
// https://stackoverflow.com/questions/4566301/htmlpurifier-with-an-html5-doctype
// Set HTMLPurifier configuration
$config->set('HTML.Doctype', 'HTML 4.01 Transitional');
$def = $config->getHTMLDefinition(true);
$def->addAttribute('a', 'href', new ParameterURIDef());
$def->addAttribute('img', 'src', new ParameterURIDef());
$config->set('Attr.EnableID', true);

// Allow specific tags and attributes
$config->set('HTML.Allowed', 'p,b,i,u,s,a[href|target],img[src|alt],ul,ol,li,blockquote,code,pre,span,hr,br,strong');

// Allow non-ASCII characters
$config->set('Core.EscapeNonASCIICharacters', false);
}
}
}

0 comments on commit b8e50f4

Please sign in to comment.