When drag and dropping a file into the webview and trying to use the path, there are a couple issues if the path has square brackets. I believe this also happens with the dialog plugin in addition to drag and drop, but I haven't explicitly tested it now that I've discovered this issue. I think it has to do with how the paths are being handled when added to the allowed scope.
If a path has both open and closed square brackets ([a].txt), then fs functions like exists fail with forbidden path: <the path>.
If a path has just an open square bracket ([a.txt), calls to fs methods fail with [Error] invalid glob pattern: Pattern syntax error near position 11: invalid range pattern. Also, other, good paths will no longer work until the app shuts down. And, if the persisted-scope plugin is in use, $APPLOCALDATA/.persisted-scope gets corrupted and no paths will work, even after the app is restarted. Deleting the .persisted-scope file fixes it until another bad path is dropped.
Drag any file(s) that does/do not have square brackets in the path or filename into the window, you should see a message fore each like /path/to/a.txt- "exists? " - true
Drag a file that has matching square brackets, e.g. [a].txt, you will see a message like forbidden path: /path/to/[a].txt, even though the path should be allowed as the user dragged it into the app
Drag a file that as a single open square bracket, e.g. [a.txt, you'll see an error like invalid glob pattern: Pattern syntax error near position 11: invalid range pattern.
Drag more files in, regardless of the name, you will see an error like that in 4, even after restarting the app.
Expected behavior
In all cases, you should see a message in the logs like /path/to/[whatever]/file.txt exists true, regardless of who many square brackets there are in the path.
Describe the bug
When drag and dropping a file into the webview and trying to use the path, there are a couple issues if the path has square brackets. I believe this also happens with the dialog plugin in addition to drag and drop, but I haven't explicitly tested it now that I've discovered this issue. I think it has to do with how the paths are being handled when added to the allowed scope.
[a].txt
), then fs functions like exists fail withforbidden path: <the path>
.[a.txt
), calls to fs methods fail with[Error] invalid glob pattern: Pattern syntax error near position 11: invalid range pattern
. Also, other, good paths will no longer work until the app shuts down. And, if the persisted-scope plugin is in use,$APPLOCALDATA/.persisted-scope
gets corrupted and no paths will work, even after the app is restarted. Deleting the.persisted-scope
file fixes it until another bad path is dropped.Reproduction
Example project: https://github.com/lendle/tauri-app-bad-filenames created with
npm create tauri-app@latest
using sveltekit. Also added fs and persisted-scope plugins and the following listener:To reproduce:
/path/to/a.txt- "exists? " - true
[a].txt
, you will see a message likeforbidden path: /path/to/[a].txt
, even though the path should be allowed as the user dragged it into the app[a.txt
, you'll see an error likeinvalid glob pattern: Pattern syntax error near position 11: invalid range pattern
.Expected behavior
In all cases, you should see a message in the logs like
/path/to/[whatever]/file.txt exists true
, regardless of who many square brackets there are in the path.Full
tauri info
outputStack trace
No response
Additional context
No response