【问题标题】:Html purifier removes image style no matter the configuration, how do I allow it?无论配置如何,Html 净化器都会删除图像样式,我该如何允许?
【发布时间】:2021-02-09 17:08:11
【问题描述】:

我正在为 Laravel 使用 https://github.com/mewebstudio/Purifier 包,我遇到了一个问题,即无论我的配置如何,样式属性总是从输入中删除。 这是我的配置

        'HTML.Allowed'  => 'font[color|style],h1[class|style],h2[class|style],h3[class|style],h4[class|style],h5[class|style],div[class|style],b,strong,i,em,a[href|title|class|style],ul,ol,li,p[style|class],br,span[style|class],img[style|width|height|alt|src|class],table[style|class],tbody[style|class],thead[style|class],tr[style|class],td[style|class],th[style|class]',
        'CSS.AllowedProperties'    => 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align,width',

这是我的意见:

<img src="http://mywebsite.deve/storage/1278/5f97ed8127418_5f8efd4d61487_image.png" class="img h-auto" style="width: 25%;" alt="" title="" role="">

这就是我应用净化器的“干净”后得到的结果

<img src="http://mywebsite.deve/storage/1278/5f97ed8127418_5f8efd4d61487_image.png" class="img h-auto" alt="">

我的配置错了吗?我已经被这个问题困扰了几个小时了,非常感谢任何帮助。

【问题讨论】:

    标签: styles sanitization htmlpurifier


    【解决方案1】:

    感谢这篇文章https://github.com/mewebstudio/Purifier/issues/68 我终于设法让它工作了。在配置中只需要添加 'CSS.MaxImgLength' => null, under 'CSS.AllowedProperties'=> '...'

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-04
      • 2021-05-08
      • 1970-01-01
      • 1970-01-01
      • 2020-03-07
      • 2014-03-27
      相关资源
      最近更新 更多