question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Less v3.0.0 incorrectly processes a base64-encoded style sheets

See original GitHub issue

If you compile the following code:

@import url("data:text/css;base64,Ym9keSB7IGJhY2tncm91bmQtY29sb3I6IGxpbWUgIWltcG9ydGFudDsgfQ==");

then get the following error:

FileError: 'data:text/css;base64,Ym9keSB7IGJhY2tncm91bmQtY29sb3I6IGxpbWUgIWltcG9ydGFudDsgfQ==' wasn't found. Tried - data:text/css;base64,Ym9keSB7IGJhY2tncm91bmQtY29sb3I6IGxpbWUgIWltcG9ydGFudDsgfQ==,C:\temp\data:text\css;base64,Ym9keSB7IGJhY2tncm91bmQtY29sb3I6IGxpbWUgIWltcG9ydGFudDsgfQ==,C:\temp\node_modules\data:text\css;base64,Ym9keSB7IGJhY2tncm91bmQtY29sb3I6IGxpbWUgIWltcG9ydGFudDsgfQ== in C:\temp\test.less on line 1, column 1:
1 @import url("data:text/css;base64,Ym9keSB7IGJhY2tncm91bmQtY29sb3I6IGxpbWUgIWltcG9ydGFudDsgfQ==");

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
matthew-deancommented, Feb 12, 2018

This was a bug actually. See #2955 for more details.

Right. So the fact it worked in 2.7.3 was actually a bug, probably just because the “css” string was indata:text/css. There is no supported/documented method to do imports in Less in this way. If you want to preserve an @import statement, you need to specify the import type as (css).

0reactions
seven-phases-maxcommented, Feb 16, 2018

The fact that this works proves that the degree of compatibility is really high.

It is, otherwise it would not be declared as a CSS superset. Still 1000 incompatibilities (of infinite language feature combinations in total) is a myriad. (It does not mean you’ll ever face more than two or three of them though. Just like most of average users will never face @import url("data:text/css;base64,Ym...).

Could you name a couple please?

A quick walk through issues here could give some ideas (it’s too tedious to build a list for even two or three when each sounds like

“Parser ignores strings at an unknown at-rule prelude (thus failing at { and ; there)”

or longer).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is embedding background image data into CSS as Base64 ...
It's not a good idea when you want your images and style information to be cached ... I don't see a problem to...
Read more >
Base64 - MDN Web Docs Glossary: Definitions of ... - Mozilla
Base64 is a group of similar binary-to-text encoding schemes that represent binary data in an ASCII string format by translating it into a ......
Read more >
invalid base64-encoded string: number of data characters (9 ...
I wager that storing at worst 2 extra bytes is far less expensive than the hassle / complexity / unexpectedness of a custom...
Read more >
Base64 Encoding & Performance, Part 2: Gathering Data
Expectedly, parsing stylesheets is dramatically slower if they're full of Base64 encoded assets. On Desktop, parsing was over 10× slower. On ...
Read more >
Data URIs | CSS-Tricks
The end result can be a site with all the less HTTP Requests, ... data:[<mime type>][;charset=<charset>][;base64],<encoded data>.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found