jekyll-sass-converter 1.3.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e214a22000c306efb48b4912d4c7b6e9d78990a
4
- data.tar.gz: 08c40d1cfb885f62ba399078cc3cbba2407dcf86
3
+ metadata.gz: 645b96822c506f0d86f27cce5dc09793c4842982
4
+ data.tar.gz: 9eff7d0b5b3f471bc4d898edeb447aae620f3601
5
5
  SHA512:
6
- metadata.gz: 543425ee1744268bf5999cae33e8faca593181b99b4b90f098751f3803a68d570d1ea6476821ed67886bc12b49a4908fdc2d65ed84c96c6602c4d7cb0c4d3dad
7
- data.tar.gz: 6ccb8315e233073715dd970ad7076a18de04d370130e606b2136df72e22ce202c09226e6fbcb74c28b20a38f5040ec85cb7829165857e9641b354d2cac22a798
6
+ metadata.gz: d06aefb9977c5861b8871db35659fc9b0e50b7870f329f83eeef738f3a5ef74ccba66c48ea989aed5f16152fc808fe0fe375c209c7938e96f9f9d16e2e4e8ee5
7
+ data.tar.gz: 2bf05d542e7e713970b2b5b3e7f4c25c95ba2b5d6f05fdaf6d1c217aa93527b911191dbe969fed816885dbeecfd1ccbd9700ed695b7ab0ff40a61e0f147e0712
@@ -1,3 +1,3 @@
1
1
  module JekyllSassConverter
2
- VERSION = "1.3.0"
2
+ VERSION = "1.5.0"
3
3
  end
@@ -1,9 +1,12 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'sass'
2
4
  require 'jekyll/utils'
3
5
 
4
6
  module Jekyll
5
7
  module Converters
6
8
  class Scss < Converter
9
+ BYTE_ORDER_MARK = /^\xEF\xBB\xBF/
7
10
  SyntaxError = Class.new(ArgumentError)
8
11
 
9
12
  safe true
@@ -68,21 +71,42 @@ module Jekyll
68
71
  end
69
72
 
70
73
  def sass_dir_relative_to_site_source
71
- Jekyll.sanitized_path(@config["source"], sass_dir)
74
+ Jekyll.sanitized_path(site_source, sass_dir)
72
75
  end
73
76
 
74
77
  def sass_load_paths
78
+ paths = user_sass_load_paths + [sass_dir_relative_to_site_source]
79
+
75
80
  if safe?
76
- [sass_dir_relative_to_site_source]
77
- else
78
- (user_sass_load_paths + [sass_dir_relative_to_site_source]).uniq
79
- end.select { |load_path| File.directory?(load_path) }
81
+ # Sanitize paths to prevent any attack vectors (.e.g. `/**/*`)
82
+ paths.map! { |path| Jekyll.sanitized_path(site_source, path) }
83
+ end
84
+
85
+ # Expand file globs (e.g. `node_modules/*/node_modules` )
86
+ Dir.chdir(site_source) do
87
+ paths = paths.map { |path| Dir.glob(path) }.flatten.uniq
88
+
89
+ paths.map! do |path|
90
+ if safe?
91
+ # Sanitize again in case globbing was able to do something crazy.
92
+ Jekyll.sanitized_path(site_source, path)
93
+ else
94
+ File.expand_path(path)
95
+ end
96
+ end
97
+ end
98
+
99
+ paths.select { |path| File.directory?(path) }
80
100
  end
81
101
 
82
102
  def allow_caching?
83
103
  !safe?
84
104
  end
85
105
 
106
+ def add_charset?
107
+ !!jekyll_sass_configuration["add_charset"]
108
+ end
109
+
86
110
  def sass_configs
87
111
  sass_build_configuration_options({
88
112
  "syntax" => syntax,
@@ -92,10 +116,17 @@ module Jekyll
92
116
  end
93
117
 
94
118
  def convert(content)
95
- ::Sass.compile(content, sass_configs)
119
+ output = ::Sass.compile(content, sass_configs)
120
+ replacement = add_charset? ? '@charset "UTF-8";' : ''
121
+ output.sub(BYTE_ORDER_MARK, replacement)
96
122
  rescue ::Sass::SyntaxError => e
97
123
  raise SyntaxError.new("#{e.to_s} on line #{e.sass_line}")
98
124
  end
125
+
126
+ private
127
+ def site_source
128
+ @site_source ||= File.expand_path(@config["source"]).freeze
129
+ end
99
130
  end
100
131
  end
101
132
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-sass-converter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Parker Moore
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-08 00:00:00.000000000 Z
11
+ date: 2016-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sass
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.2'
19
+ version: '3.4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.2'
26
+ version: '3.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -70,14 +70,14 @@ dependencies:
70
70
  name: jekyll
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '2.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '2.0'
83
83
  description:
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  version: '0'
112
112
  requirements: []
113
113
  rubyforge_project:
114
- rubygems_version: 2.2.2
114
+ rubygems_version: 2.5.1
115
115
  signing_key:
116
116
  specification_version: 4
117
117
  summary: A basic Sass converter for Jekyll.