Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invisible Unicode Character 'FORM FEED (FF)' (U+000C) is always injected into image-set CSS rule #2943

Closed
voronianski opened this issue Nov 16, 2022 · 4 comments · Fixed by #3025

Comments

@voronianski
Copy link

voronianski commented Nov 16, 2022

Current behavior:

After upgrading to React v18.2.0 and Emotion v11.10.5, Emotion components started to insert an invisible character inside CSS image-set and -webkit-image-set rules. It always appears in the first url() after first & character.

Inserted character looks like some sort of invisible space and breaks CSS. Examples of broken CSS -

image

To reproduce:

Use this link - https://codesandbox.io/s/confident-water-tsbbj6?file=/src/App.js

  1. Check WorkingExample in DevConsole and notice that backround-image CSS is correctly recognized by browser
    image

  2. Check BrokenExample in DevConsole and notice that backround-image CSS in invalid -

image

You can copy-paste CSS from BrokenExample into some CSS Validator to see this invisible char -

image

Expected behavior:

background-image with image-set and -webkit-image-set rules work as expected.

Environment information:

  • react version: 18.2.0
  • @emotion/react version: 11.10.5
  • @emotion/styled version: 11.10.5
@voronianski voronianski changed the title Invisible space injected into image-set CSS rule Invisible unicode character is always injected into image-set CSS rule Nov 16, 2022
@voronianski voronianski changed the title Invisible unicode character is always injected into image-set CSS rule Invisible Unicode Character 'FORM FEED (FF)' (U+000C) is always injected into image-set CSS rule Nov 16, 2022
@voronianski
Copy link
Author

voronianski commented Nov 16, 2022

After debugging the CSS string, it looks like 0c unicode char is injected -

Unicode Character 'FORM FEED (FF)' (U+000C) https://www.fileformat.info/info/unicode/char/0c/index.htm

Found out by pasting CSS string into - https://www.soscisurvey.de/tools/view-chars.php
image

@Andarist
Copy link
Member

This is the problem within the parser that we use. We are investigating this here: thysultan/stylis#307

@voronianski
Copy link
Author

@Andarist do you think there‘s a way to workaround it somehow, until it gets fixed?

@Andarist
Copy link
Member

You could write a Stylis plugin that would replace &\f with & in declaration values and use it with createCache+CacheProvider

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants