Add --whitelist flag and internal logic
This commit is contained in:
parent
480e35037b
commit
a4b9bab1dc
|
@ -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|
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue