summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-09-11 08:47:13 +0000
committerDouwe Maan <douwe@gitlab.com>2015-09-11 08:47:13 +0000
commit4f461fd45f65dbd6900088149b48649b27a7c2ce (patch)
tree2a05b8ef187db81f059b59f71a6cdcbbc2c465c1 /lib
parenta5bb85f8a234b2d8463656877712faf10f5bb842 (diff)
parente3c97ede9663fe7905fcb350875c46526cb4f832 (diff)
downloadgitlab-ce-4f461fd45f65dbd6900088149b48649b27a7c2ce.tar.gz
Merge branch 'rs-fix-highlighting' into 'master'
Syntax highlighting improvements On the server side: During development I would occasionally see SanitizationFilter sanitizing the result of SyntaxHighlightFilter, even though its attributes were whitelisted. This updates the `clean_spans` transformer to return the whitelisted node as [suggested by the Sanitize docs](http://git.io/vZR8i). On the client side: - Makes the syntax_highlight JS more flexible - Adds JS specs - Simplifies highlighting of new notes - Adds highlighting to Markdown preview See merge request !1278
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/markdown/sanitization_filter.rb12
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..e368de7d848 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