htmlpurifier与borderRadius [英] htmlpurifier with borderRadius

查看:192
本文介绍了htmlpurifier与borderRadius的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何允许带有htmlpurifier的borderRadius?

How do I allow borderRadius with htmlpurifier?

我发现这个,但它似乎不适用于当前版本的htmlpurifier,也许他们改变了你添加的方式您自己的css?

I found this but it doesn't seem to work with current version of htmlpurifier, perhaps they changed the way you add your own css?

http://htmlpurifier.org/phorum/read.php?2,6154,6154

  $config = HTMLPurifier_Config::createDefault();

  // add some custom CSS3 properties                                                                                                                                              
  $css_definition = $config->getDefinition('CSS');

  $border_radius =
    $info['border-top-left-radius'] =
    $info['border-top-right-radius'] =
    $info['border-bottom-left-radius'] =
    $info['border-bottom-right-radius'] =
    new HTMLPurifier_AttrDef_CSS_Composite(array(
                                             new HTMLPurifier_AttrDef_CSS_Length('0'),
                                             new HTMLPurifier_AttrDef_CSS_Percentage(true)
                                             ));

  $info['border-radius'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_radius);

  // wrap all new attr-defs with decorator that handles !important                                                                                                                
  $allow_important = $config->get('CSS.AllowImportant');
  foreach ($info as $k => $v) {
    $css_definition->info[$k] = new HTMLPurifier_AttrDef_CSS_ImportantDecorator($v, $allow_important);
  }

  $html_purifier = new HTMLPurifier($config);


推荐答案

在此处可以找到代码

https:/ /github.com/msvensson82/htmlpurifier

我基本上只是将它添加到CSSDefinition.php文件,如果你想修改你的,而不是得到我的repo 。

I basically just added this to the CSSDefinition.php file, if you wish to amend yours instead of getting my repo.

// border-radius
$border_radius =
$this->info['border-top-left-radius'] =
$this->info['border-top-right-radius'] =
$this->info['border-bottom-left-radius'] =
$this->info['border-bottom-right-radius'] = new HTMLPurifier_AttrDef_CSS_Composite(array(
 new HTMLPurifier_AttrDef_CSS_Length('0'),
 new HTMLPurifier_AttrDef_CSS_Percentage(true)
));
$this->info['border-radius'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_radius);

这篇关于htmlpurifier与borderRadius的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆