sveltejs / vite-plugin-svelte

Svelte plugin for http://vitejs.dev/
MIT License
840 stars 102 forks source link

Could not open +page.svelte in the editor #943

Open Loizzus opened 2 months ago

Loizzus commented 2 months ago

Describe the bug

Randomly started getting this error on my Svelte projects recently when using the code inspector to open up files. Have no idea how to resolve. It only affects files with special characters in the name.

Could not open +page.svelte in the editor.

When running on Windows, file names are checked against a safe file name pattern to protect against remote code execution attacks. File names may consist only of alphanumeric characters (all languages), periods, dashes, slashes, and underscores.

Reproduction URL

https://github.com/sveltejs/vite-plugin-svelte/issues/new

Reproduction

Sorry, do not know how to replicate. Looking for advice on how to fix.

Logs

No response

System Info

Windows 11, VS Code, Tested with Brave and Edge
dominikg commented 2 months ago

caused by https://github.com/yyx990803/launch-editor/commit/5366f3ee3addc9ea014088c254db6398f788fbff

launch-editor tries to protect from malicious filenames, not sure if + is a dangerous char on windoes or just too rigid check

dominikg commented 2 months ago

fix could take a bit as launch-editor is bundled in vite

dominikg commented 2 months ago

The linked change was included in vite 5.3.2

Haukez commented 1 month ago

and how to fix this now? I got most recent versions and still get this error.

dominikg commented 1 month ago

this needs a change in launch-editor first and then vite has to update the bundled version and release that.

Loizzus commented 1 month ago

As a temporary fix force vite to be version 5.3.1 in your package.json: "devDependencies": { "vite": "5.3.1" }, "overrides": { "@sveltejs/vite-plugin-svelte": { "vite": "5.3.1" } }

dominikg commented 1 month ago

please don't use partial overrides. If svelte-inspector on +page.svelte files is that important to you, go back to vite 5.3.1 entirely to ensure that you are using one consistent version.

dominikg commented 1 month ago

the fix for this is going to be included in the next release of vite

Wizzel1 commented 1 month ago

Still doesn't work for me with "vite": "^5.4.0",

dominikg commented 1 month ago

Still doesn't work for me with "vite": "^5.4.0",

can you provide more info here? the fix was pretty straight forward and another windows user just reported it working with 5.4.

can you open files that do not contain a + in their name? Which windows shell and ide versions?

Wizzel1 commented 1 month ago

Yes, I sometimes can open files that don't contain a + but it's hit and miss.

Sometimes even navigating to a component fails:

app:dev: Could not open BulkReplaceSheet.svelte in the editor.
app:dev: 
app:dev: When running on Windows, file names are checked against a safe file name pattern to protect against remote code execution attacks. File names may consist only of alphanumeric 
characters (all languages), periods, dashes, slashes, and underscores.

My vscode version is 1.92.0 and I am running powershell

dominikg commented 1 month ago

Does your username or the project directory contain any other special characters?

Wizzel1 commented 1 month ago

This is the path to one of my pages. Closest character to a special character is the underscore. Unbenannt

dominikg commented 1 month ago

oof, [] and () are problems tooo i guess

oneezy commented 2 weeks ago

can confirm this is still an issue with vite 5.4.2

Could not open Title.svelte in the editor.

When running on Windows, file names are checked against a safe file name pattern 
to protect against remote code execution attacks. File names may consist only of 
alphanumeric characters (all languages), periods, dashes, slashes, and underscores.

image


Referencing

issue: https://github.com/yyx990803/launch-editor/issues/50 pull: https://github.com/yyx990803/launch-editor/issues/50 commit: https://github.com/yyx990803/launch-editor/commit/5366f3ee3addc9ea014088c254db6398f788fbff