Add --whitelist flag and internal logic

This commit is contained in:
Parker Moore 2013-10-25 13:25:44 -04:00
parent 480e35037b
commit a4b9bab1dc
2 changed files with 10 additions and 4 deletions

View File

@ -41,6 +41,7 @@ def add_build_options(c)
c.option '--lsi', 'Use LSI for improved related posts' c.option '--lsi', 'Use LSI for improved related posts'
c.option '-D', '--drafts', 'Render posts in the _drafts folder' c.option '-D', '--drafts', 'Render posts in the _drafts folder'
c.option '-V', '--verbose', 'Print verbose output.' c.option '-V', '--verbose', 'Print verbose output.'
c.option '-W', '--whitelist', 'Gem plugin whitelist'
end end
command :default do |c| command :default do |c|

View File

@ -3,7 +3,8 @@ module Jekyll
attr_accessor :config, :layouts, :posts, :pages, :static_files, attr_accessor :config, :layouts, :posts, :pages, :static_files,
:categories, :exclude, :include, :source, :dest, :lsi, :pygments, :categories, :exclude, :include, :source, :dest, :lsi, :pygments,
:permalink_style, :tags, :time, :future, :safe, :plugins, :limit_posts, :permalink_style, :tags, :time, :future, :safe, :plugins, :limit_posts,
:show_drafts, :keep_files, :baseurl, :data, :file_read_opts, :gems :show_drafts, :keep_files, :baseurl, :data, :file_read_opts,
:gems, :whitelist
attr_accessor :converters, :generators attr_accessor :converters, :generators
@ -98,14 +99,18 @@ module Jekyll
def require_gems def require_gems
self.gems.each do |gem| self.gems.each do |gem|
if gem_whitelist.include?(gem) || !self.safe if whitelist.include?(gem) || !self.safe
require gem require gem
end end
end end
end end
def gem_whitelist def whitelist
@gem_whitelist ||= [] @whitelist ||= begin
YAML.safe_load_file(self.config['whitelist']) || []
rescue
[]
end
end end
# Internal: Setup the plugin search path # Internal: Setup the plugin search path