Skip to content

Commit

Permalink
Append theme's sass path after all sanitizations (#96)
Browse files Browse the repository at this point in the history
Merge pull request 96
  • Loading branch information
ashmaroli authored and jekyllbot committed Sep 26, 2019
1 parent efecf50 commit 83f6375
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
6 changes: 1 addition & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ language: ruby
rvm:
- &latest_ruby 2.6
- 2.4
matrix:
include:
- rvm: *latest_ruby
env: JEKYLL_VERSION=3.8.6
env:
matrix:
- JEKYLL_VERSION=4.0.0.pre.alpha1
- JEKYLL_VERSION=4.0
branches:
only:
- master
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ source "https://rubygems.org"
gemspec

gem "jekyll", ENV["JEKYLL_VERSION"] ? "~> #{ENV["JEKYLL_VERSION"]}" : ">= 3.0"
gem "minima"
2 changes: 1 addition & 1 deletion lib/jekyll/converters/scss.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ def sass_dir_relative_to_site_source
# rubocop:disable Metrics/AbcSize
def sass_load_paths
paths = user_sass_load_paths + [sass_dir_relative_to_site_source]
paths << site.theme.sass_path if site.theme&.sass_path

if safe?
# Sanitize paths to prevent any attack vectors (.e.g. `/**/*`)
Expand All @@ -150,6 +149,7 @@ def sass_load_paths
end
end

paths << site.theme.sass_path if site.theme&.sass_path
paths.select { |path| File.directory?(path) }
end
# rubocop:enable Metrics/AbcSize
Expand Down
32 changes: 32 additions & 0 deletions spec/scss_converter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,38 @@ def converter(overrides = {})
end
end

context "with valid sass paths in a theme" do
context "in unsafe mode" do
let(:site) do
Jekyll::Site.new(
site_configuration.merge("theme" => "minima")
)
end

it "includes the theme's sass directory" do
expect(site.theme.sass_path).to be_truthy
expect(converter.sass_load_paths).to include(site.theme.sass_path)
end
end

context "in safe mode" do
let(:site) do
Jekyll::Site.new(
site_configuration.merge(
"theme" => "minima",
"safe" => true
)
)
end

it "includes the theme's sass directory" do
expect(site.safe).to be true
expect(site.theme.sass_path).to be_truthy
expect(converter.sass_load_paths).to include(site.theme.sass_path)
end
end
end

context "in a site with a collection labelled 'pages'" do
let(:site) do
make_site(
Expand Down

0 comments on commit 83f6375

Please sign in to comment.