elementary / elementary/files

FileChooser: Directory separator in the filename entry is passed to the caller without validation.

Open
#2,016 10 comments 1 reaction 0 assignees View on GitHub
Priority: Medium
Dominant language
Vala
Stars
365
Forks
82
Avg merge
4d 2h
Merged PRs (30d)
3

Description

### What Happened?

When I enter invalid characters into a filename, the filechooser exits silently and then seems to cause undefined behavior in the app. The behavior varies a bit by app in terms of how the resulting file is handled, but the chooser always closes with no warning, as if the save had succeeded. But no file is saved to the file system, at least on either of the apps I tried (Code and Apostrophe).

### Steps to Reproduce

1. Open a new document in Code
2. Press the `Save As` button and navigate to some directory you'll remember
3. Enter a file name with a slash, like `Stuff/Things.txt` and press `Save` to try to save the file in that directory
4. The dialog will close immediately
5. (This is Code specific, but may show part of the behavior:) The portion of the filename you entered (like `Things.txt` appears in the tab title
6. Open Files to the directory you tried to save the file to. The file will not be there, so it was never saved.

If I repeat the same process in Apostrophe, clicking `Save` multiple times and re-entering the same invalid file name will never save a file, so the app will always put up the file chooser dialog. Code will silently fail to save from there on. This is what I mean by how behavior differs. But I don't think the invalid name should be passed to the apps in the first place.

### Expected Behavior

Some warning should appear that the filename contains invalid characters and suggest the appropriate changes.

### OS Version

6.x (Odin)

### Software Version

Compiled from git

### Log Output

_No response_

### Hardware Info

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.