-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from ArchBlood/enh/allow-symbol-translations
Enh: Allow predefined tags, attributes and non-ASCII characters
- Loading branch information
Showing
1 changed file
with
10 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |