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(css): #3729 filter out function name suffixes with url #3752

Merged
merged 2 commits into from
Jun 14, 2021

Conversation

Sociosarbis
Copy link
Contributor

@Sociosarbis Sociosarbis commented Jun 10, 2021

Description

fix #3729

https://github.com/vitejs/vite/blob/main/packages/vite/src/node/plugins/css.ts#L800-L808

old regExp would rewrite this

 @function svg-url($string) { 
 @return ""; 
 } 

to something like due to the rebase process on importing file

 @function svg-url(@a/a/svg/$string) { 
 @return ""; 
 } 

Additional context

Is there any case the new regExp hasn't covered ?


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@Shinigami92 Shinigami92 added the p3-minor-bug An edge case that only affects very specific usage (priority) label Jun 10, 2021
Shinigami92
Shinigami92 previously approved these changes Jun 10, 2021
@patak-dev
Copy link
Member

I think that ( would also be valid before url here. Instead of whitelisting all possible cases, maybe it is better to do the regex the other way around and don't match if url is a suffix for a valid function name?

mask-image: image(url(mask.png), skyblue, linear-gradient(rgba(0, 0, 0, 1.0), transparent));

@Sociosarbis
Copy link
Contributor Author

I think that ( would also be valid before url here. Instead of whitelisting all possible cases, maybe it is better to do the regex the other way around and don't match if url is a suffix for a valid function name?

mask-image: image(url(mask.png), skyblue, linear-gradient(rgba(0, 0, 0, 1.0), transparent));

Thank your for reminding me.

I read the section of identier code point in this docs and have rewritten previous committed code.

@underfin underfin merged commit 9aa255a into vitejs:main Jun 14, 2021
javastation pushed a commit to javastation/vite that referenced this pull request Jun 22, 2021
aleclarson pushed a commit to aleclarson/vite that referenced this pull request Jun 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Certain variable and function name in scss can cause fatal error in vite
4 participants