-
Notifications
You must be signed in to change notification settings - Fork 1.3k
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Error "Invalid UTF-8 sequence" and "Not enough space" when compiling ANSI files (WINDOWS) #2281
Comments
@xelloss1012 thanks for the report. Apologies for the regression. I've confirmed the issues you've mentioned on LibSass 3.5.0. I'm current debugging #2280 which is relatively urgent. I'll don't expect to get to this before tomorrow. cc @mgreter you might know where to look off the top of your head. |
This is intended behavior to avoid invalid parsing results (as reported multiple times) and unexpected segfaults when printing error messages etc. We currently only support utf8 (and therefore plain ascii). Supporting single byte encodings should be possible though (detecting charset and replace everything utf8 related with single byte logic) ... https://www.w3.org/International/questions/qa-choosing-encodings |
@xelloss1012 apologies I didn't notice the breaking change. As a work around for now you'll need to lock to |
Ok, for me there is no problem, we have version locked to 4.7 to avoid this issue and I think we can live with this by the moment :) But I suspect this issue can be affecting a number of users, since ANSI is the default encoding used in Windows and in some Windows developer tools like Visual Studio... In special to non english users that may be writing comments with special characters, etc. Thank you very much for your comments! |
Hello again, We recently have been trying to update to the new node LTS (10.13.0) but then our node-sass that was locked to 4.7 version (to prevent the ANSI problem) does not work, since this version of node-sass is not compatible with node > 9. As a workaround, we have've been trying to read ourselves the files (with a custom funcion to deal with the ANSI encoding) and then sending the resulting string to the "data" parameter instead of the "file" parameter. This works... unless you have some imported files (mixins, functions, etc.) with the same problem (ANSI files with special characters). To solve this, we've been trying to use the "importer" parameter. But, since the importer doesn't send you the resolved path but the import string as it is written in the file, in order to use it we need to do some tricky extra work to resolve the filepath... and it seems very dirty and prone to errors (in fact, I still haven't been able to make it to resolve properly some paths)... We currently have something like this:
Before trying to fix my customImporter function, I would like to know if I'm in the right direction or if there is a better way to solve this problem. Maybe some way to just override the "read" function to be used when reading the files to be compiled and their dependencies... or a way to receive a parameter in the importer function with the file path already resolved by libsass, so we can rewrite just the read part without having to reimplement the path resolving... Thank you in advance. |
Just in case someone reads this... :) I think I've finally come up with the solution. There was some error in the code, so making some slight modifications seems to work properly:
|
Not enough space can be explained this way: The byte |
@xelloss1012 The importer looks good to me, you might only check if But still the best is to convert your source to UTF-8. |
Issue
When trying to compile files that are encoding as ANSI (Windows-1252) and have some special characters (i.e. ñ, á, é, etc.), even if this characters are only in a comment, we are getting 2 types of error.
We use this code to compile the files:
Then, when trying to compile a file with this exact contents:
We get this error:
And when trying to compile a file with this other contents:
We get a different error:
I think both errors are the same, since sometimes changing a little the contents of the file it appears one error or the other.
I have attached the problematic files so you can reproduce the error in an easier way.
test ansi node-sass 4.8.1.zip
Is important to note that this error only happens when the file is encoded as ANSI (Windows-1252). When the file is encoded as UTF-8 it works perfectly. However, even if a file is encoded as UTF-8 (or as ANSI but without any special characters), the error also occurs if any of its import files meets this conditions.
Note that in node-sass 4.7.2 was working great (with libsass 3.5.0.beta.2) so it seems related to the latest release of node-sass 4.8.1 (with libsass 3.5.0).
System info
npm -v
): 5.6.0node -v
): v8.9.4node -p process.versions
):{ http_parser: '2.7.0',
node: '8.9.4',
v8: '6.1.534.50',
uv: '1.15.0',
zlib: '1.2.11',
ares: '1.10.1-DEV',
modules: '57',
nghttp2: '1.25.0',
openssl: '1.0.2n',
icu: '59.1',
unicode: '9.0',
cldr: '31.0.1',
tz: '2017b' }
node -p process.platform
): win32node -p process.arch
): x64node -p "require('node-sass').info"
):node-sass 4.8.1 (Wrapper) [JavaScript]
libsass 3.5.0 (Sass Compiler) [C/C++]
npm ls node-sass
): node-sass@4.8.1The text was updated successfully, but these errors were encountered: