diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-09-05 17:50:47 -0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-09-10 15:08:06 -0400 |
commit | 7cbf5e4d18f6ba0bf1afbddcb090fa39837e9529 (patch) | |
tree | 672522ec84e0ef60efccf001313bcc3370064141 | |
parent | b2f3d024c3775f9d8dc293c433da103381ed6e45 (diff) | |
download | gitlab-ce-7cbf5e4d18f6ba0bf1afbddcb090fa39837e9529.tar.gz |
Prevent result of SyntaxHighlightFilter being sanitized
-rw-r--r-- | lib/gitlab/markdown/sanitization_filter.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/gitlab/markdown/sanitization_filter.rb b/lib/gitlab/markdown/sanitization_filter.rb index 68ed57f6257..54faf981b7d 100644 --- a/lib/gitlab/markdown/sanitization_filter.rb +++ b/lib/gitlab/markdown/sanitization_filter.rb @@ -67,12 +67,16 @@ module Gitlab def clean_spans lambda do |env| - return unless env[:node_name] == 'span' - return unless env[:node].has_attribute?('class') + node = env[:node] - unless has_ancestor?(env[:node], 'pre') - env[:node].remove_attribute('class') + return unless node.name == 'span' + return unless node.has_attribute?('class') + + unless has_ancestor?(node, 'pre') + node.remove_attribute('class') end + + {node_whitelist: [node]} end end end |