diff options
author | Robert Speicher <rspeicher@gmail.com> | 2016-02-22 01:33:35 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2016-02-22 01:33:35 +0300 |
commit | 4225fd229f8503c3007e07cbad2ccac319b2547b (patch) | |
tree | 0e0243eeb41a784551172ca020fe7702e9cf9dfb /lib/banzai | |
parent | 1367caa642e7ec9a46f202b6149a01e7093c573d (diff) |
Sanitize `data:` links
Closes #13625
Diffstat (limited to 'lib/banzai')
-rw-r--r-- | lib/banzai/filter/sanitization_filter.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/banzai/filter/sanitization_filter.rb b/lib/banzai/filter/sanitization_filter.rb index 04ddfe53ed6..c201ace8d35 100644 --- a/lib/banzai/filter/sanitization_filter.rb +++ b/lib/banzai/filter/sanitization_filter.rb @@ -43,8 +43,8 @@ module Banzai # Allow any protocol in `a` elements... whitelist[:protocols].delete('a') - # ...but then remove links with the `javascript` protocol - whitelist[:transformers].push(remove_javascript_links) + # ...but then remove links with unsafe protocols + whitelist[:transformers].push(remove_unsafe_links) # Remove `rel` attribute from `a` elements whitelist[:transformers].push(remove_rel) @@ -55,14 +55,14 @@ module Banzai whitelist end - def remove_javascript_links + def remove_unsafe_links lambda do |env| node = env[:node] return unless node.name == 'a' return unless node.has_attribute?('href') - if node['href'].start_with?('javascript', ':javascript') + if node['href'].start_with?('javascript', ':javascript', 'data') node.remove_attribute('href') end end |