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

Fix #3698 #3373 - parsing variables fail when there is no trailing semicolon #3700

Merged
merged 1 commit into from Jan 15, 2023

Conversation

b-kelly
Copy link
Contributor

@b-kelly b-kelly commented Mar 9, 2022

What:

Added a fix for the parser crashing when a css variable property does not end with a semicolon. Fixes #3698 and Fixes #3373.

Why:

This helps to avoid crashes when importing pre-minified css files from e.g. an npm package. In our case, cssnano always drops the trailing semicolon on the last property. This cannot be disabled without disabling all of whitespace normalization (normalizeWhitespace option). Fixing the bug in Less.js fixes this use case for us.

How:

When calling permissiveValue on a detected css variable, the untilTokens parameter is left unset. This defaults it to detecting ; for ending the value. I've set the parameter to /[;}]/ instead in order to close variables on either the semicolon (;) or the closing curly bracket (}) character. This may not be the most optimal fix, but it gets the job done in the test cases I've added. Additionally, it doesn't break any of the existing test cases.

Checklist:

  • Documentation N/A
  • Added/updated unit tests
  • Code complete

@matthew-dean
Copy link
Member

Oh, thanks for taking a look at this!

@abhishek4794
Copy link

Hi,

Can we merge this pr?
I am still getting this issue

#3373

@liuqiangqiang0624
Copy link

same here,can we merge this ?

@iChenLei
Copy link
Member

iChenLei commented Oct 20, 2022

ping @matthew-dean

@matthew-dean matthew-dean merged commit 0e99701 into less:master Jan 15, 2023
@baileyandy
Copy link

Hi, is there any chance we can get a release of less with this fix in soon please?

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

Successfully merging this pull request may close these issues.

css variable without end semicolon get a compiler error Error when using css variables without semi.
6 participants