mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-09-02 18:32:48 +02:00
[1.6.0] Add support for bgcolor attribute transform.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@919 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
28
library/HTMLPurifier/AttrTransform/BgColor.php
Normal file
28
library/HTMLPurifier/AttrTransform/BgColor.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
require_once 'HTMLPurifier/AttrTransform.php';
|
||||
|
||||
/**
|
||||
* Pre-transform that changes deprecated bgcolor attribute to CSS.
|
||||
*/
|
||||
class HTMLPurifier_AttrTransform_BgColor
|
||||
extends HTMLPurifier_AttrTransform {
|
||||
|
||||
function transform($attr, $config, &$context) {
|
||||
|
||||
if (!isset($attr['bgcolor'])) return $attr;
|
||||
|
||||
$bgcolor = $attr['bgcolor'];
|
||||
unset($attr['bgcolor']);
|
||||
// some validation should happen here
|
||||
|
||||
$attr['style'] = isset($attr['style']) ? $attr['style'] : '';
|
||||
$attr['style'] = "background-color:$bgcolor;" . $attr['style'];
|
||||
|
||||
return $attr;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@@ -6,7 +6,7 @@ require_once 'HTMLPurifier/AttrTransform.php';
|
||||
* Pre-transform that changes deprecated align attribute to text-align.
|
||||
*/
|
||||
class HTMLPurifier_AttrTransform_TextAlign
|
||||
extends HTMLPurifier_AttrTransform {
|
||||
extends HTMLPurifier_AttrTransform {
|
||||
|
||||
function transform($attr, $config, &$context) {
|
||||
|
||||
|
Reference in New Issue
Block a user