如何启用丝瓜络使用 css url 功能?
How to enable using css url function with loofah?
我已经尝试过的:
Loofah::HTML5::WhiteList::ACCEPTABLE_CSS_FUNCTIONS.add 'url'
Loofah::HTML5::WhiteList::ACCEPTABLE_CSS_PROPERTIES.add 'background-image'
但是
Rails::Html::WhiteListSanitizer.new.sanitize_css 'background-image: url(https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png);'
returns“”
使用 rgb 进行测试:
Rails::Html::WhiteListSanitizer.new.sanitize_css 'background-image: rgb(https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png);'
returns
'background-image:rgb(https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png);'
与Loofah::HTML5::Scrub.scrub_css
我有相同的结果。
丝瓜版本:2.13.0
Rails 版本:6.1.4.4
在 Rails 控制台中测试
恐怕它不起作用,因为 url 过滤器 is hardcoded。
我已经尝试过的:
Loofah::HTML5::WhiteList::ACCEPTABLE_CSS_FUNCTIONS.add 'url'
Loofah::HTML5::WhiteList::ACCEPTABLE_CSS_PROPERTIES.add 'background-image'
但是
Rails::Html::WhiteListSanitizer.new.sanitize_css 'background-image: url(https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png);'
returns“”
使用 rgb 进行测试:
Rails::Html::WhiteListSanitizer.new.sanitize_css 'background-image: rgb(https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png);'
returns
'background-image:rgb(https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png);'
与Loofah::HTML5::Scrub.scrub_css
我有相同的结果。
丝瓜版本:2.13.0
Rails 版本:6.1.4.4
在 Rails 控制台中测试
恐怕它不起作用,因为 url 过滤器 is hardcoded。