FIX: properly whitelist <code> classes needed for syntax highlighting

This commit is contained in:
Régis Hanol 2014-07-09 16:27:47 +02:00
parent 9ffcbfca98
commit 6b45b635f8
5 changed files with 15 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/*global Markdown:true BetterMarkdown:true */
/*global Markdown:true, hljs:true */
/**
Contains methods to help us with markdown formatting.
@ -226,6 +226,7 @@ Discourse.Markdown = {
}
};
RSVP.EventTarget.mixin(Discourse.Markdown);
Discourse.Markdown.whiteListTag('a', 'class', 'attachment');
@ -238,13 +239,13 @@ Discourse.Markdown.whiteListTag('a', 'data-bbcode');
Discourse.Markdown.whiteListTag('div', 'class', 'title');
Discourse.Markdown.whiteListTag('div', 'class', 'quote-controls');
// FIXME: explicitly whitelist classes we need allowed through for
// syntax highlighting, grab from highlight.js
// explicitly whitelist classes we need allowed through for
// syntax highlighting, grabbed from highlight.js
hljs.listLanguages().forEach(function (language) {
Discourse.Markdown.whiteListTag('code', 'class', language);
});
Discourse.Markdown.whiteListTag('code', 'class', 'text');
Discourse.Markdown.whiteListTag('code', 'class', 'ruby');
Discourse.Markdown.whiteListTag('code', 'class', 'json');
Discourse.Markdown.whiteListTag('code', 'class', 'lang-auto');
// Discourse.Markdown.whiteListTag('code', 'class', '*');
Discourse.Markdown.whiteListTag('span', 'class', 'mention');
Discourse.Markdown.whiteListTag('span', 'class', 'spoiler');

View File

@ -5,6 +5,8 @@
// Pagedown customizations
//= require ./pagedown_custom.js
//= require highlight.pack.js
// Stuff we need to load first
//= require ./discourse/mixins/scrolling
//= require_tree ./discourse/mixins

View File

@ -49,7 +49,7 @@ module Discourse
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
config.assets.paths += %W(#{config.root}/config/locales)
config.assets.paths += %W(#{config.root}/config/locales #{config.root}/public/javascripts)
# explicitly precompile any images in plugins ( /assets/images ) path
config.assets.precompile += [lambda do |filename, path|

File diff suppressed because one or more lines are too long

View File

@ -21,9 +21,11 @@
// Pagedown customizations
//= require ../../app/assets/javascripts/pagedown_custom.js
//
//= require ../../public/javascripts/highlight.pack.js
//= require vendor
//
//= require htmlparser.js
// Stuff we need to load first