Cssnano: surprising behaviour with U+FFFC OBJECT REPLACEMENT CHARACTER

Created on 18 Nov 2016  Â·  7Comments  Â·  Source: cssnano/cssnano

node node_modules/cssnano-cli/cmd.js  << EOF
.c { a: 'b';}
EOF
echo

or

echo '.c { a: 'b';}' | node node_modules/cssnano-cli/cmd.js

will both surprisingly output
.c{:b}

with the "a" gone.

Expected behaviour:

  • bark at the included U+FFFC OBJECT REPLACEMENT CHARACTER in utf-8 encoding

Usecase:
This character somehow got into my style file after copying something from the development
tools of Chromium, especially the elements inspector. I could not see the character in the editor
or the terminal, so it took me a while until I've found the problem. The current silent fail makes cssnano a fragile component.

echo '.c { a: 'b';}' | hexdump -C
00000000  2e 63 20 7b ef bf bc 20  61 3a 20 62 3b 7d 0a     |.c {... a: b;}.|

Tested with [email protected]

bug upstream

All 7 comments

Crazy thing :(. It relevant to PostCSS. Could you create some simple test like "a: \ufffc b" — I will see what I can do

My hope was that the commands above are able to serve as simple test cases, they work right away when copied into a GNU/Linux shell (I'm using bash, which is a common default) depending on how you call cssnano (or the releveant postcss processor). What else would you need for a simple test case?

@bernhardreiter JS string :).

UNIX command could not be used in JS tests :(

/cc @ai problem still exists? Can we move this to postcss problem?

Retesting:

yarn add cssnano-cli
yarn list cssnano
#└─ [email protected]
echo '.c { a: 'b';}' | node node_modules/cssnano-cli/cmd.js
.c{:b }
# problem still there

It looks like the a ends up in node.raws.between. When we override it, a disappears. a should be part of node.prop, so it's definitely an upstream issue.

\cc @ai

Upstream repo has decided not to fix this.

Was this page helpful?
0 / 5 - 0 ratings