You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Plugins that use the emptyString() function have a serious issue when they're activated while the raw code has a RegExp expression with a single or double quote inside.
test('strings',()=>{constclean=emptyString(` // comment1 const a = 'aaaa' /* coment2 */ const b = "bbbb" const regexp = /'/ const c = "cccc" // ' /* // coment3 */ /* // coment3 */ // comment 4 /* comment 5 */ `)expect(clean).toMatch("const a = '\0\0\0\0'")expect(clean).toMatch('const b = "\0\0\0\0"')expect(clean).toMatch('const c = "\0\0\0\0"')})
In this test, the entire const c assignment is clobbered over with null characters due to the single quotes surrounding it in the RegExp and in the comment. In cases where the "matching" single quote occurs in the middle of a statement, major parsing errors occur and the whole build can fail.
Reproduction
I'm having trouble isolating this in vite.new, but it's fairly straightforward to reproduce in the unit test file. I can work on providing a repo if it's absolutely necessary.
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead.
Describe the bug
Plugins that use the
emptyString()
function have a serious issue when they're activated while the raw code has a RegExp expression with a single or double quote inside.In this test, the entire
const c
assignment is clobbered over with null characters due to the single quotes surrounding it in the RegExp and in the comment. In cases where the "matching" single quote occurs in the middle of a statement, major parsing errors occur and the whole build can fail.Reproduction
I'm having trouble isolating this in vite.new, but it's fairly straightforward to reproduce in the unit test file. I can work on providing a repo if it's absolutely necessary.
System Info
Used Package Manager
pnpm
Logs
Validations
The text was updated successfully, but these errors were encountered: