Bug 421075 - Trailing Whitespace when creating directories or files.
Summary: Trailing Whitespace when creating directories or files.
Status: RESOLVED FIXED
Alias: None
Product: dolphin
Classification: Applications
Component: panels: folders (show other bugs)
Version: 19.04.3
Platform: Kubuntu Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: Nate Graham
URL:
Keywords:
: 383376 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-05-05 20:03 UTC by Larry Dewey
Modified: 2020-05-26 16:13 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.71


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Larry Dewey 2020-05-05 20:03:11 UTC
SUMMARY

When creating a file or directory in Dolphin, if the user places a leading or trailing white space in the name, it leaves it there. Spaces in between multiple words should be honored, but all others should be stripped.

STEPS TO REPRODUCE

1. Open Dolphin
2. Right click
3. Create New
4. Select any of the options
5. Enter any name with a leading or trailing white space

OBSERVED RESULT

// Trailing white space
Creates "<directory_or_filename> "
// or
// Leading white space 
Creates " <directory_or_filename>"
// or
// Leading and trailing white space.
Creates " <directory_or_filename> "

EXPECTED RESULT

// No leading or trailing white space
Creates "<directory_or_filename>"


SOFTWARE/OS VERSIONS

Operating System: Kubuntu 19.10
KDE Plasma Version: 5.16.5
KDE Frameworks Version: 5.62.0
Qt Version: 5.12.4
Kernel Version: 5.3.0-7648-generic
OS Type: 64-bit
Processors: 8 × Intel® Core™ i5-10210U CPU @ 1.60GHz
Memory: 15.5 GiB of RAM


ADDITIONAL INFORMATION

Dolphin Version: 19.04.3
Bug occurs in the following distributions:
- Ubuntu:
  - 16.04, 16.10, 17.04, 17.10, 18.04, 18.10, 19.04, 19.10, 20.04
- openSUSE:
  - Tumbleweed, Leap 15.1
- Fedora:
  - 31, 32
- Arch
Comment 1 Nate Graham 2020-05-05 20:08:00 UTC
Can you explain why you think this should happen? What problem is it causing you? Bug reports that just describe a problem are usually more helpful than ones that propose a solution without explaining the problem.
Comment 2 Larry Dewey 2020-05-05 20:39:21 UTC
(In reply to Nate Graham from comment #1)
> Can you explain why you think this should happen? What problem is it causing
> you? Bug reports that just describe a problem are usually more helpful than
> ones that propose a solution without explaining the problem.

Can you explain why you think this should happen?

There are a number of reasons that I feel it should happen:

1. Consistency with other file managers.
   - Nautilus, Thunar, Nemo, etc all prevent you from entering 
     a name with a trailing or leading white space.
2. Ease of use.
   - In most instances users do not mean to place a leading
     or trailing white space when naming their directories or
     file names.
   - Saving files to samba, nfs, or sshfs file shares fail to
     save when not quoted or escaped.
   - Output while in command line directory tree fails to
     clearly show spaces when in such a directory.
3. Navigation from the command line.
   - Without quoting or escaping the space at the beginning or
     end of the file or directory name, you may end up in an
     undesired location.
   - Allows for duplicate directory naming. For example, 
     "python stuff" and "python stuff " or " python stuff".
     while this could easily be blamed on the user, it could
     also be prevented from happening.

What problem is it causing you?

I currently have an nfs share, a samba share, and an sshfs
share all connected to my Kubuntu machine. When trying to
transfer documents, it throws an error because the intened
destination was unable to be found (due to the space). While
it is easily fixed by removing the space, it could have been
avoided in the first place by stripping the leading/trailing
white spaces from the name of the file or directory.

Also, my son and wife use this computer, and tend to
inadvertently leave a trailing space after the name. Which
causes frustration for them.

(In reply to Nate Graham from comment #1)
> ...Bug reports that just describe a problem are usually more helpful than
> ones that propose a solution without explaining the problem.

I agree that fully understanding what is happening is helpful
for debugging. Having dealt with many bugs, myself, I also try
to prevent detail overloads. Hope this helps clarify what I
am experiencing.
Comment 3 Christoph Feck 2020-05-05 20:48:35 UTC
It could warn about those spaces (and offer to remove them), but never silently drop them.
Comment 4 Larry Dewey 2020-05-05 21:17:05 UTC
(In reply to Christoph Feck from comment #3)
> It could warn about those spaces (and offer to remove them), but never
> silently drop them.

I understand why you never want to do something without the user knowing about it. Especially when the user DOES mean to have them there. At the same time, I feel like wanting them there is more of the edge case than the vase majority. Would it be possible to remove, warn, potentially and prompt to leave the spaces in (with an option to disable the warning in settings)? Then the majority of users will get the expected experience, while edge case users can still keep the customization of the naming?
Comment 5 2wxsy58236r3 2020-05-06 09:31:25 UTC
Maybe we can implement a warning similar to D15980 and D21907? [1] [2]

[1] https://phabricator.kde.org/D15980
[2] https://phabricator.kde.org/D21907
Comment 6 Nate Graham 2020-05-06 14:08:54 UTC
Seems reasonable.
Comment 7 Nate Graham 2020-05-06 14:20:48 UTC
https://phabricator.kde.org/D29483
Comment 8 Nate Graham 2020-05-19 04:42:01 UTC
Git commit 9aa00db018ffe842f20cf01dbe62cbac0d09bf4a by Nate Graham.
Committed on 19/05/2020 at 04:41.
Pushed by ngraham into branch 'master'.

[knewfilemenu] Show inline warning when creating items with leading or trailing spaces

Summary:
This is a somewhat unusual thing for a user to do intentionally, so let's show a
warning to make sure they're aware that they're doing it.
FIXED-IN: 5.71

Test Plan:
{F8289470, size=full}
{F8289471, size=full}

Reviewers: #frameworks, #vdg, cfeck, cblack

Reviewed By: #vdg, cblack

Subscribers: kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D29483

M  +14   -0    src/filewidgets/knewfilemenu.cpp

https://invent.kde.org/frameworks/kio/commit/9aa00db018ffe842f20cf01dbe62cbac0d09bf4a
Comment 9 Nate Graham 2020-05-19 17:15:56 UTC
*** Bug 383376 has been marked as a duplicate of this bug. ***
Comment 10 David de Cos 2020-05-23 17:37:45 UTC
Say you're typing the name of an item which is composed of two or more words separated by spaces. Does the message appear as soon as you press the space bar, and disappear when you type the first letter of the next word? In my opinion, that could be distracting.
Comment 11 phrxmd 2020-05-26 10:54:06 UTC
Because the filename starts or ends with a space, the message now shows two spaces either after "This name" or after the filename; maybe better either to enclose the filename in quotes, or to strip tailing/leading spaces.
Comment 12 Nate Graham 2020-05-26 16:02:10 UTC
Good point. I will submit a follow-up merge request.