How can I configure HTML Purifier to allow data UR

2019-04-24 08:36发布

How can I allow base64 data for the the src attribute of image tags? I see code like this:

$config->set('URI.AllowedSchemes', array('http' => true, 'https' => true, 'mailto' => true, 'ftp' => true, 'nntp' => true, 'news' => true, 'data' => true));

In this case, is it data => true which allows the base64? And if so, how can I allow base64 data only for the src attribute of the img tag? (I do not want to allow data URIs in other situations.)

I thought of doing something like:

$ def-> addAttribute ('a', 'target', 'Enum # _blank, _self, _target, _top');     

But in my case like this:

$ def-> addAtribute ('img', 'src', 'Enum # data, http, https, ...);

Is this possible?

1条回答
我想做一个坏孩纸
2楼-- · 2019-04-24 08:53

Easy: just only have data in your allowed schemes:

$config->set('URI.AllowedSchemes', array('data' => true));
查看更多
登录 后发表回答