我已經嘗試過的:
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);'
回傳“”
使用 RGB 進行測驗:
Rails::Html::WhiteListSanitizer.new.sanitize_css 'background-image: rgb(https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png);'
回傳
'background-image:rgb(https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png);'
與Loofah::HTML5::Scrub.scrub_css我有相同的結果。
絲瓜版本:2.13.0
導軌版本:6.1.4.4
在 Rails 控制臺中測驗
uj5u.com熱心網友回復:
恐怕它不起作用,因為 url 過濾器是硬編碼的。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/429662.html
