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(assets): avoid splitting , inside base64 value of srcset attribute #15422

Merged
merged 7 commits into from Dec 30, 2023

Conversation

chaejunlee
Copy link
Contributor

fixes #15419

Description

As mentioned in the issue, when parsing srcset, the , inside base64 value was getting split and joined again, breaking the base64 encoding.

The comment of splitSrcSet says that it is handling "data:..." case. But RE itself is only catching single or double quotes. I added additional RE logic to capture the whole base64 values.

Additional context


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, especially the Pull Request Guidelines.
  • 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).
  • Update the corresponding documentation if needed.
  • Ideally, include relevant tests that fail without this PR but pass with it.

Copy link

stackblitz bot commented Dec 25, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@chaejunlee chaejunlee changed the title fix: escape splitting , inside base64 value within srcset attribute of img fix(utils): escape splitting , inside base64 value within srcset attribute of img Dec 25, 2023
@chaejunlee chaejunlee changed the title fix(utils): escape splitting , inside base64 value within srcset attribute of img fix(node): escape splitting , inside base64 value within srcset attribute of img Dec 25, 2023
packages/vite/src/node/utils.ts Outdated Show resolved Hide resolved
packages/vite/src/node/__tests__/utils.spec.ts Outdated Show resolved Hide resolved
@bluwy bluwy changed the title fix(node): escape splitting , inside base64 value within srcset attribute of img fix(assets): avoid splitting , inside base64 value of srcset attribute Dec 26, 2023
@bluwy bluwy added the p3-minor-bug An edge case that only affects very specific usage (priority) label Dec 26, 2023
Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great 👍

@sapphi-red sapphi-red merged commit 8de7bd2 into vitejs:main Dec 30, 2023
10 checks passed
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.

srcset with base64 value is mangled on build
4 participants