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

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

Closed
Loizzus opened this issue Jul 14, 2024 · 24 comments
Closed

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

Loizzus opened this issue Jul 14, 2024 · 24 comments
Labels
bug Something isn't working upstream vite

Comments

@Loizzus
Copy link

Loizzus commented Jul 14, 2024

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
@Loizzus Loizzus added bug Something isn't working triage Awaiting triage by a project member labels Jul 14, 2024
@dominikg
Copy link
Member

caused by yyx990803/launch-editor@5366f3e

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

@dominikg
Copy link
Member

dominikg commented Jul 14, 2024

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

@dominikg
Copy link
Member

The linked change was included in vite 5.3.2

@Haukez
Copy link

Haukez commented Jul 29, 2024

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

@dominikg
Copy link
Member

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

@Loizzus
Copy link
Author

Loizzus commented Jul 29, 2024

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
Copy link
Member

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
Copy link
Member

dominikg commented Aug 6, 2024

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

@Wizzel1
Copy link

Wizzel1 commented Aug 7, 2024

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

@dominikg
Copy link
Member

dominikg commented Aug 7, 2024

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
Copy link

Wizzel1 commented Aug 8, 2024

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
Copy link
Member

dominikg commented Aug 8, 2024

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

@Wizzel1
Copy link

Wizzel1 commented Aug 8, 2024

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

@dominikg
Copy link
Member

dominikg commented Aug 8, 2024

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

@oneezy
Copy link

oneezy commented Aug 24, 2024

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: yyx990803/launch-editor#50
pull: yyx990803/launch-editor#50
commit: yyx990803/launch-editor@5366f3e

@rogueyoshi
Copy link

rogueyoshi commented Sep 20, 2024

Happening for me on Win10 as well, after update to latest version of SvelteKit 2.

Only seems to happen when inspecting elements on routes (+page.svelte), or on components not inside of routes with params. I'm guessing '+' and '[]' are not on the aforementioned safe file name pattern. Components living anywhere else seem to work fine.

image

@Wizzel1
Copy link

Wizzel1 commented Oct 5, 2024

Any updates on this?

@dominikg
Copy link
Member

dominikg commented Oct 5, 2024

latest version of launch-editor and vite should have this fixed. if you still experience files that do not open please share their full path (skip your user dir for privacy if you prefer but mention if it has any special chars)

@Wizzel1
Copy link

Wizzel1 commented Oct 5, 2024

latest version of launch-editor and vite should have this fixed. if you still experience files that do not open please share their full path (skip your user dir for privacy if you prefer but mention if it has any special chars)

So I am running VSCode 1.94.0 and vite 5.4.8. Maybe its the underscore in my repo name?
Unbenannt

@Loizzus
Copy link
Author

Loizzus commented Oct 8, 2024

Can confirm, issue has not been fixed for Svelte 4.
image

Also the plugin does not work at all in Svelte 5.

@Loizzus
Copy link
Author

Loizzus commented Oct 8, 2024

Actually a simple test project does work. However I tested this path from an actual production project and it fails:
C:\Users\loic.joachim\Documents\GitHub\nodejs-external\src\routes\portal\(orders)\ordermanagement\+page.svelte
Presumably because of the -

@dominikg
Copy link
Member

The fix is in launch-editor 2.9.1 which has been merged into vite main branch (6.0 beta) but not backported to 5.4 branch yet, sorry. still needs to wait a bit

@dominikg
Copy link
Member

please try again with vite 5.4.9

@Wizzel1
Copy link

Wizzel1 commented Oct 14, 2024

please try again with vite 5.4.9

Yes it works now, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream vite
Projects
None yet
Development

No branches or pull requests

6 participants