Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 7ec14df

Browse files
committed
Bump LibSass@3.5.3
1 parent eb5ad0a commit 7ec14df

26 files changed

Lines changed: 257 additions & 136 deletions

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "node-sass",
33
"version": "4.9.0",
4-
"libsass": "3.5.2",
4+
"libsass": "3.5.3",
55
"description": "Wrapper around libsass",
66
"license": "MIT",
77
"bugs": "https://github.com/sass/node-sass/issues",
@@ -83,7 +83,7 @@
8383
"object-merge": "^2.5.1",
8484
"read-yaml": "^1.0.0",
8585
"rimraf": "^2.5.2",
86-
"sass-spec": "^3.5.1",
86+
"sass-spec": "3.5.3",
8787
"unique-temp-dir": "^1.0.0"
8888
}
8989
}

src/libsass/GNUmakefile.am

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -25,63 +25,49 @@ else
2525
AM_CXXFLAGS += -std=c++0x
2626
endif
2727

28+
TEST_EXTENSIONS = .rb
29+
2830
if ENABLE_TESTS
2931

30-
noinst_PROGRAMS = tester
32+
SASS_SASSC_PATH ?= $(top_srcdir)/sassc
33+
SASS_SPEC_PATH ?= $(top_srcdir)/sass-spec
3134

35+
noinst_PROGRAMS = tester
3236
tester_LDADD = src/libsass.la
33-
tester_SOURCES = $(SASS_SASSC_PATH)/sassc.c
34-
tester_VERSION ?= `cd "$(SASS_SASSC_PATH)" && ./version.sh`
35-
tester_CFLAGS = $(AM_CFLAGS) -DSASSC_VERSION="\"$(tester_VERSION)\""
36-
tester_CXXFLAGS = $(AM_CXXFLAGS) -DSASSC_VERSION="\"$(tester_VERSION)\""
3737
tester_LDFLAGS = $(AM_LDFLAGS)
38+
nodist_tester_SOURCES = $(SASS_SASSC_PATH)/sassc.c
39+
SASS_SASSC_VERSION ?= `cd "$(SASS_SASSC_PATH)" && ./version.sh`
40+
tester_CFLAGS = $(AM_CFLAGS) -DSASSC_VERSION="\"$(SASS_SASSC_VERSION)\""
41+
tester_CXXFLAGS = $(AM_CXXFLAGS) -DSASSC_VERSION="\"$(SASS_SASSC_VERSION)\""
3842

3943
if ENABLE_COVERAGE
4044
nodist_EXTRA_tester_SOURCES = non-existent-file-to-force-CXX-linking.cxx
4145
endif
4246

43-
SASS_SASSC_PATH ?= $(top_srcdir)/sassc
44-
SASS_SPEC_PATH ?= $(top_srcdir)/sass-spec
45-
46-
TESTS = \
47-
$(SASS_SPEC_PATH)/spec/basic \
48-
$(SASS_SPEC_PATH)/spec/css \
49-
$(SASS_SPEC_PATH)/spec/extend-tests \
50-
$(SASS_SPEC_PATH)/spec/extends \
51-
$(SASS_SPEC_PATH)/spec/libsass \
52-
$(SASS_SPEC_PATH)/spec/libsass-closed-issues \
53-
$(SASS_SPEC_PATH)/spec/maps \
54-
$(SASS_SPEC_PATH)/spec/misc \
55-
$(SASS_SPEC_PATH)/spec/regressions \
56-
$(SASS_SPEC_PATH)/spec/scss \
57-
$(SASS_SPEC_PATH)/spec/scss-tests \
58-
$(SASS_SPEC_PATH)/spec/types
47+
TESTS = $(SASS_SPEC_PATH)/sass-spec.rb
48+
RB_LOG_COMPILER = ./script/tap-runner
49+
AM_RB_LOG_FLAGS = $(RUBY)
5950

6051
SASS_TEST_FLAGS = -V 3.5 --impl libsass
61-
LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) ./script/tap-driver
62-
AM_LOG_FLAGS = -c ./tester $(LOG_FLAGS)
63-
if USE_TAP
64-
AM_LOG_FLAGS += -t
65-
SASS_TEST_FLAGS += -t | tapout
66-
LOG_COMPILER = ./script/tap-runner $(RUBY) $(SASS_SPEC_PATH)/sass-spec.rb
67-
else
68-
LOG_COMPILER = $(RUBY) $(SASS_SPEC_PATH)/sass-spec.rb
69-
endif
52+
SASS_TEST_FLAGS += -r $(SASS_SPEC_PATH)
53+
SASS_TEST_FLAGS += -c $(top_srcdir)/tester$(EXEEXT)
54+
AM_TESTS_ENVIRONMENT = TEST_FLAGS='$(SASS_TEST_FLAGS)'
7055

7156
SASS_TESTER = $(RUBY) $(SASS_SPEC_PATH)/sass-spec.rb
72-
SASS_TESTER += -c $(top_srcdir)/tester$(EXEEXT)
7357

7458
test:
75-
$(SASS_TESTER) $(LOG_FLAGS) $(SASS_SPEC_PATH) $(SASS_TEST_FLAGS)
59+
$(SASS_TESTER) $(SASS_TEST_FLAGS)
7660

7761
test_build:
78-
$(SASS_TESTER) $(LOG_FLAGS) $(SASS_SPEC_PATH) $(SASS_TEST_FLAGS)
62+
$(SASS_TESTER) $(SASS_TEST_FLAGS)
7963

8064
test_full:
81-
$(SASS_TESTER) --run-todo $(LOG_FLAGS) $(SASS_SPEC_PATH) $(SASS_TEST_FLAGS)
65+
$(SASS_TESTER) --run-todo $(SASS_TEST_FLAGS)
8266

8367
test_probe:
84-
$(SASS_TESTER) --probe-todo $(LOG_FLAGS) $(SASS_SPEC_PATH) $(SASS_TEST_FLAGS)
68+
$(SASS_TESTER) --probe-todo $(SASS_TEST_FLAGS)
69+
70+
.PHONY: test test_build test_full test_probe
8571

8672
endif
8773

src/libsass/configure.ac

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ AC_CONFIG_MACRO_DIR([m4])
99
AC_CONFIG_HEADERS([src/config.h])
1010
AC_CONFIG_FILES([include/sass/version.h])
1111
AC_CONFIG_AUX_DIR([script])
12+
1213
# These are flags passed to automake
1314
# Though they look like gcc flags!
1415
AM_INIT_AUTOMAKE([foreign parallel-tests -Wall])
@@ -93,21 +94,16 @@ the --with-sass-spec-dir=<dir> argument.
9394
;;
9495
esac
9596
AC_SUBST(SASS_SPEC_PATH)
96-
97-
# TODO: Remove this when automake requirements are 1.12+
98-
AC_MSG_CHECKING([whether we can use TAP mode])
99-
tmp=`$AWK '/TEST_LOG_DRIVER/' $srcdir/GNUmakefile.in`
100-
if test "x$tmp" != "x"; then
101-
use_tap=yes
102-
else
103-
use_tap=no
104-
fi
105-
AC_MSG_RESULT([$use_tap])
106-
97+
else
98+
# we do not really need these paths for non test build
99+
# but automake may error if we do not define them here
100+
SASS_SPEC_PATH=sass-spec
101+
SASS_SASSC_PATH=sassc
102+
AC_SUBST(SASS_SPEC_PATH)
103+
AC_SUBST(SASS_SASSC_PATH)
107104
fi
108105

109106
AM_CONDITIONAL(ENABLE_TESTS, test "x$enable_tests" = "xyes")
110-
AM_CONDITIONAL(USE_TAP, test "x$use_tap" = "xyes")
111107

112108
AC_ARG_ENABLE([coverage],
113109
[AS_HELP_STRING([--enable-coverage],

src/libsass/docs/implementations.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,32 @@ There are several implementations of `libsass` for a variety of languages. Here
1414
* [go_sass](https://github.com/suapapa/go_sass)
1515
* [go-sass](https://github.com/SamWhited/go-sass)
1616

17+
### Haskell
18+
* [hLibsass](https://github.com/jakubfijalkowski/hlibsass)
19+
* [hSass](https://github.com/jakubfijalkowski/hsass)
20+
21+
### Java
22+
* [libsass-maven-plugin](https://github.com/warmuuh/libsass-maven-plugin)
23+
* [jsass](https://github.com/bit3/jsass)
24+
25+
### JavaScript
26+
* [sass.js](https://github.com/medialize/sass.js)
27+
1728
### Lua
1829
* [lua-sass](https://github.com/craigbarnes/lua-sass)
1930

2031
### .NET
2132
* [libsass-net](https://github.com/darrenkopp/libsass-net)
2233
* [NSass](https://github.com/TBAPI-0KA/NSass)
2334
* [Sass.Net](https://github.com/andyalm/Sass.Net)
35+
* [SharpScss](https://github.com/xoofx/SharpScss)
36+
* [LibSassHost](https://github.com/Taritsyn/LibSassHost)
2437

25-
### node.js
26-
* [node-sass](https://github.com/andrew/node-sass)
27-
28-
### Java
29-
* [libsass-maven-plugin](https://github.com/warmuuh/libsass-maven-plugin)
30-
* [jsass](https://github.com/bit3/jsass)
38+
### Nim
39+
* [nim-sass](https://github.com/zacharycarter/nim-sass)
3140

32-
### JavaScript
33-
* [sass.js](https://github.com/medialize/sass.js)
41+
### node.js
42+
* [node-sass](https://github.com/sass/node-sass)
3443

3544
### Perl
3645
* [CSS::Sass](https://github.com/caldwell/CSS-Sass)

src/libsass/docs/unicode.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
1-
LibSass currently expects all input to be utf8 encoded (and outputs only utf8), if you actually have any unicode characters at all. We do not support conversion between encodings, even if you declare it with a `@charset` rule. The text below was originally posted as an [issue](https://github.com/sass/libsass/issues/381) on the LibSass tracker.
1+
LibSass currently expects all input to be utf8 encoded (and outputs only utf8), if you actually have any unicode characters at all. We do not support conversion between encodings, even if you declare it with a `@charset` rule. The text below was originally posted as an [issue](https://github.com/sass/libsass/issues/381) on the LibSass tracker. Since then the status is outdated as LibSass now expects your
2+
input to be utf8/ascii compatible, as it has been proven that reading ANSI (e.g. single byte encodings) as utf8 can lead to unexpected
3+
behavior, which can in the worst case lead to buffer overruns/segfaults. Therefore LibSass now checks your input to be valid utf8 encoded!
24

35
### [Declaring character encodings in CSS](http://www.w3.org/International/questions/qa-css-charset.en)
46

5-
This [explains](http://www.w3.org/International/questions/qa-css-charset.en) how the character encoding of a css file is determined. Since we are only dealing with local files, we never have a HTTP header. So the precedence should be 'charset' rule, byte-order mark (BOM) or auto-detection (finally falling back to system default/UTF-8). This may not sound too hard to implement, but what about import rules? The CSS specs do not forbid the mixing of different encodings! I solved that by converting all files to UTF-8 internally. On writing there is an option to tell the tool what encoding it should be (UTF-8 by default). One can also define if it should write a BOM or not and if it should add the charset declaration.
7+
This [explains](http://www.w3.org/International/questions/qa-css-charset.en) how the character encoding of a css file is determined. Since we are only dealing with local files, we never have a HTTP header. So the precedence should be 'charset' rule, byte-order mark (BOM) or auto-detection (finally falling back to system default/UTF-8). This may not sound too hard to implement, but what about import rules? The CSS specs do not forbid the mixing of different encodings! I [solved that](https://github.com/mgreter/webmerge/) by converting all files to UTF-8 internally. On writing there is an option to tell the tool what encoding it should be (UTF-8 by default). One can also define if it should write a BOM or not and if it should add the charset declaration.
68

7-
Since my tool is written in perl, I have a lot of utilities at hand to deal with different unicode charsets. I'm pretty sure that most OSS uses [libiconv](https://www.gnu.org/software/libiconv/) to convert between different encodings. But I have now idea how easy/hard this would be to integrate platform independent (it seems doable).
9+
Since my [tool]((https://github.com/mgreter/webmerge/)) is written in perl, I have a lot of utilities at hand to deal with different unicode charsets. I'm pretty sure that most OSS uses [ICU](http://site.icu-project.org/) or [libiconv](https://www.gnu.org/software/libiconv/) to convert between different encodings. But I have now idea how easy/hard this would be to integrate platform independent (it seems doable). ANSII (single byte encoding) to utf8 is basically just a conversion table (for every supported code-page).
810

911
### Current status on LibSass unicode support
1012

11-
Currently LibSass seems to handle the common UTF-8 case pretty well. I believe it should correctly support all ASCII compatible encodings (like UTF-8 or Latin-1). If all includes use the same encoding, the output should be correct (in the same encoding). It should also handle unicode chars in [selectors, variable names and other identifiers](https://github.com/hcatlin/libsass/issues/244#issuecomment-34681227). This is true for all ASCII compatible encodings. So the main incompatible encodings (I'm aware of) are UTF-16/UTF-32 (which could be converted to UTF-8 with libiconv).
13+
LibSass should/is fully UTF (and therefore plain ASCII) compatible.
14+
15+
~~Currently LibSass seems to handle the common UTF-8 case pretty well. I believe it should correctly support all ASCII compatible encodings (like UTF-8 or Latin-1). If all includes use the same encoding, the output should be correct (in the same encoding). It should also handle unicode chars in [selectors, variable names and other identifiers](https://github.com/hcatlin/libsass/issues/244#issuecomment-34681227). This is true for all ASCII compatible encodings. So the main incompatible encodings (I'm aware of) are UTF-16/UTF-32 (which could be converted to UTF-8 with libiconv).~~
16+
17+
LibSass 3.5 will enforce that your input is either plain ASCII (chars below 127) or utf8. It does not handle anything else, but therefore ensures that the output is in a valid form. Before version 3.5 you were able to mix different code-pages, which yielded unexpected behavior.
1218

1319
### Current encoding auto detection
1420

15-
LibSass currently reads all kind of BOMs and will error out if it finds something it doesn't know how to handle! It seems that it throws away the optional UTF-8 BOM (if any is found). IMO it would be nice if users could configure that (also if a charset rule should be added to the output).
21+
LibSass currently reads all kind of BOMs and will error out if it finds something it doesn't know how to handle! It seems that it throws away the optional UTF-8 BOM (if any is found). IMO it would be nice if users could configure that (also if a charset rule should be added to the output). But it does not really take any `@charset` into account, it always assumes your input is utf8 and ignores any given `@charset`!
1622

1723
### What is currently not supported
1824

19-
- Using non ASCII compatible encodings (like UTF-16)
25+
- Using non ASCII compatible encodings (like UTF-16, Latin-1 etc.)
2026
- Using non ASCII characters in different encodings in different includes
2127

2228
### What is missing to support the above cases
2329

24-
- A way to convert between encodings (like libiconv)
30+
- A way to convert between encodings (like libiconv/ICU)
2531
- Sniffing the charset inside the file (source is available)
2632
- Handling the conversion on import (and export)
2733
- Optional: Make output encoding configurable
@@ -31,9 +37,9 @@ LibSass currently reads all kind of BOMs and will error out if it finds somethin
3137

3238
I guess the current implementation should handle more than 99% of all real world use cases.
3339
A) Unicode characters are still seldomly seen (as they can be written escaped)
34-
B) It will still work if it's UTF-8 or in any of the most common known western ISO codepages.
35-
Although I'm not sure how this applies to asian and other "exotic" codepages!
40+
~~B) It will still work if it's UTF-8 or in any of the most common known western ISO codepages.
41+
Although I'm not sure how this applies to asian and other "exotic" codepages!~~
3642

37-
I guess the biggest Problem is to have libiconv (or some other) library as a dependency. Since it contains a lot of rules for the conversions, I see it as the only way to handle this correctly. Once that is sorted out it should be pretty much straight forward to implement the missing pieces (in parser.cpp - Parser::parse should return encoding and add Parser::sniff_charset, then convert the source byte stream to UTF-8).
43+
I guess the biggest Problem is to have libiconv/ICU (or some other) library as a dependency. Since it contains a lot of rules for the conversions, I see it as the only way to handle this correctly. Once that is sorted out it should be pretty much straight forward to implement the missing pieces (in parser.cpp - Parser::parse should return encoding and add Parser::sniff_charset, then convert the source byte stream to UTF-8).
3844

3945
I hope the statements above all hold true. Unicode is really not the easiest topic to wrap your head around. But since I did all the above recently in Perl, I wanted to document it here. Feel free to extend or criticize.

src/libsass/include/sass/context.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ ADDAPI size_t ADDCALL sass_compiler_get_callee_stack_size(struct Sass_Compiler*
149149
ADDAPI Sass_Callee_Entry ADDCALL sass_compiler_get_last_callee(struct Sass_Compiler* compiler);
150150
ADDAPI Sass_Callee_Entry ADDCALL sass_compiler_get_callee_entry(struct Sass_Compiler* compiler, size_t idx);
151151

152+
// Push function for import extenions
153+
ADDAPI void ADDCALL sass_option_push_import_extension (struct Sass_Options* options, const char* ext);
154+
152155
// Push function for paths (no manipulation support for now)
153156
ADDAPI void ADDCALL sass_option_push_plugin_path (struct Sass_Options* options, const char* path);
154157
ADDAPI void ADDCALL sass_option_push_include_path (struct Sass_Options* options, const char* path);

src/libsass/script/tap-runner

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
$@ | tapout tap
1+
$@ $TEST_FLAGS --tap --silent | tapout tap

src/libsass/src/context.cpp

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ namespace Sass {
9696
// include_paths.push_back(CWD);
9797

9898
// collect more paths from different options
99+
collect_extensions(c_options.extension);
100+
collect_extensions(c_options.extensions);
99101
collect_include_paths(c_options.include_path);
100102
collect_include_paths(c_options.include_paths);
101103
collect_plugin_paths(c_options.plugin_path);
@@ -166,6 +168,37 @@ namespace Sass {
166168
{
167169
}
168170

171+
void Context::collect_extensions(const char* exts_str)
172+
{
173+
if (exts_str) {
174+
const char* beg = exts_str;
175+
const char* end = Prelexer::find_first<PATH_SEP>(beg);
176+
177+
while (end) {
178+
std::string ext(beg, end - beg);
179+
if (!ext.empty()) {
180+
extensions.push_back(ext);
181+
}
182+
beg = end + 1;
183+
end = Prelexer::find_first<PATH_SEP>(beg);
184+
}
185+
186+
std::string ext(beg);
187+
if (!ext.empty()) {
188+
extensions.push_back(ext);
189+
}
190+
}
191+
}
192+
193+
void Context::collect_extensions(string_list* paths_array)
194+
{
195+
while (paths_array)
196+
{
197+
collect_extensions(paths_array->string);
198+
paths_array = paths_array->next;
199+
}
200+
}
201+
169202
void Context::collect_include_paths(const char* paths_str)
170203
{
171204
if (paths_str) {
@@ -236,15 +269,20 @@ namespace Sass {
236269
// looks for alternatives and returns a list from one directory
237270
std::vector<Include> Context::find_includes(const Importer& import)
238271
{
272+
// include configured extensions
273+
std::vector<std::string> exts(File::defaultExtensions);
274+
if (extensions.size() > 0) {
275+
exts.insert(exts.end(), extensions.begin(), extensions.end());
276+
}
239277
// make sure we resolve against an absolute path
240278
std::string base_path(rel2abs(import.base_path));
241279
// first try to resolve the load path relative to the base path
242-
std::vector<Include> vec(resolve_includes(base_path, import.imp_path));
280+
std::vector<Include> vec(resolve_includes(base_path, import.imp_path, exts));
243281
// then search in every include path (but only if nothing found yet)
244282
for (size_t i = 0, S = include_paths.size(); vec.size() == 0 && i < S; ++i)
245283
{
246284
// call resolve_includes and individual base path and append all results
247-
std::vector<Include> resolved(resolve_includes(include_paths[i], import.imp_path));
285+
std::vector<Include> resolved(resolve_includes(include_paths[i], import.imp_path, exts));
248286
if (resolved.size()) vec.insert(vec.end(), resolved.begin(), resolved.end());
249287
}
250288
// return vector
@@ -365,6 +403,14 @@ namespace Sass {
365403
// process the resolved entry
366404
else if (resolved.size() == 1) {
367405
bool use_cache = c_importers.size() == 0;
406+
if (resolved[0].deprecated) {
407+
// emit deprecation warning when import resolves to a .css file
408+
deprecated(
409+
"Including .css files with @import is non-standard behaviour which will be removed in future versions of LibSass.",
410+
"Use a custom importer to maintain this behaviour. Check your implementations documentation on how to create a custom importer.",
411+
true, pstate
412+
);
413+
}
368414
// use cache for the resource loading
369415
if (use_cache && sheets.count(resolved[0].abs_path)) return resolved[0];
370416
// try to read the content of the resolved file entry

src/libsass/src/context.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ namespace Sass {
6767

6868
std::vector<std::string> plugin_paths; // relative paths to load plugins
6969
std::vector<std::string> include_paths; // lookup paths for includes
70+
std::vector<std::string> extensions; // lookup extensions for imports`
7071

7172

7273

@@ -109,6 +110,8 @@ namespace Sass {
109110
void collect_plugin_paths(string_list* paths_array);
110111
void collect_include_paths(const char* paths_str);
111112
void collect_include_paths(string_list* paths_array);
113+
void collect_extensions(const char* extensions_str);
114+
void collect_extensions(string_list* extensions_array);
112115
std::string format_embedded_source_map();
113116
std::string format_source_mapping_url(const std::string& out_path);
114117

src/libsass/src/cssize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ namespace Sass {
559559

560560
std::string m1 = std::string(mq1->is_restricted() ? "only" : mq1->is_negated() ? "not" : "");
561561
std::string t1 = mq1->media_type() ? mq1->media_type()->to_string(ctx.c_options) : "";
562-
std::string m2 = std::string(mq2->is_restricted() ? "only" : mq1->is_negated() ? "not" : "");
562+
std::string m2 = std::string(mq2->is_restricted() ? "only" : mq2->is_negated() ? "not" : "");
563563
std::string t2 = mq2->media_type() ? mq2->media_type()->to_string(ctx.c_options) : "";
564564

565565

0 commit comments

Comments
 (0)