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

No escaping spaces in dropped filenames #474

Closed
Carmina16 opened this issue Sep 2, 2018 · 11 comments · Fixed by lxqt/qtermwidget#418
Closed

No escaping spaces in dropped filenames #474

Carmina16 opened this issue Sep 2, 2018 · 11 comments · Fixed by lxqt/qtermwidget#418

Comments

@Carmina16
Copy link

If a file is dropped into the terminal which has spaces in its name, it should be quoted. QTerminal doesn't quote it or even escaping spaces.

@yan12125 yan12125 added the bug label Sep 2, 2018
@yan12125
Copy link
Member

yan12125 commented Sep 2, 2018

This function is commented out as it relies on a KDE library kcoreaddons

https://github.com/lxqt/qtermwidget/blob/540c00ffc323846bd7af25b4bf1392dea20c9baa/lib/TerminalDisplay.cpp#L3135

@agaida
Copy link
Member

agaida commented Sep 2, 2018

Hmm - the question is: Might be kcoreaddons useful for us in other places too - as kcoreaddons are tier1 i would have no big problems to add the dependency.

% LANG=C apt show libkf5coreaddons5                     
Package: libkf5coreaddons5
Version: 5.49.0-1
Priority: optional
Section: libs
Source: kcoreaddons
Installed-Size: 691 kB
Depends: libkf5coreaddons-data (= 5.49.0-1), shared-mime-info (>= 1.3), libc6 (>= 2.14), libfam0, libgcc1 (>= 1:3.0), libqt5core5a (>= 5.11.0~rc1), libstdc++6 (>= 4.5)
Download-Size: 208 kB
Description: KDE Frameworks 5 addons to QtCore
 KCoreAddons provides classes built on top of QtCore to perform various tasks
 such as manipulating mime types, autosaving files, creating backup files,
 generating random sequences, performing text manipulations such as macro
 replacement, accessing user information and many more.
 .
 This package is part of KDE Frameworks 5.

@agaida
Copy link
Member

agaida commented Sep 2, 2018

@tsujan @palinek @luis-pereira @yan12125 - if the addons could solve problem and not introduce new ones - why not? I remember that we depend on kcoreaddons times ago, but don't exactly remember why we dropped them.

@palinek
Copy link
Contributor

palinek commented Sep 2, 2018

I, personally, don't see the OP as a bug, but a normal behavior. The user has to know if escaping is needed and do escape, what he/she need to escape.

@agaida
Copy link
Member

agaida commented Sep 2, 2018

@palinek - i would see it as a feature too

@tsujan
Copy link
Member

tsujan commented Sep 2, 2018

I see it as a good feature. If it can be added relatively easily, why not?

@agaida agaida added this to Wishlist in Issues Sep 2, 2018
@agaida agaida added enhancement and removed bug labels Sep 2, 2018
@agaida agaida moved this from Wishlist to Sprint in Issues Sep 15, 2018
@agaida agaida added this to To do in Issues Nov 26, 2018
@apjanke
Copy link
Contributor

apjanke commented Mar 9, 2019

I, personally, don't see the OP as a bug, but a normal behavior. The user has to know if escaping is needed and do escape, what he/she need to escape.

This isn't the case in all terminals. For example, iTerm2 can automatically do escaping of filenames for drag-and-dropped files. And there are zsh or bash add-ons that support quoting or escaping arbitrarily pasted text. The underlying terminal feature used is "bracketed paste mode", which puts a special terminal control sequence before and after pasted text. Then the receiving program (e.g. a shell or text editor) can decide what to do with it, like quoting or escaping it according to their semantics. The terminal knows what text is literal pasted text and needs to be escaped, and the receiving program knows how to do escaping.

Maybe QTerminal could add bracketed paste mode support, and let the shell handle the escaping? It might be hard for QTerminal to do quoting of filenames etc. itself, because it doesn't necessarily know the quoting syntax of the frontmost program running inside the terminal.

@yan12125
Copy link
Member

yan12125 commented Mar 9, 2019

I think escaping should be done by the terminal emulator rather than the shell as only the former knows where the string comes from. The string shouldn't be escaped if it's just some plain texts (e.g. dragged-and-dropped from a paragraph on a webpage). As you can see in a linked code segment above, QMimeData handles this.

if the addons could solve problem and not introduce new ones - why not?

Just an implementation note - as KF5 does not work well on macOS due to an Qt bug [1], there should be a CMake option to build qterm* without KF5.

By the way, bracketed paste works fine on Linux. If it doesn't work for you, it might be a macOS-specific issue.

[1] https://bugreports.qt.io/browse/QTBUG-62420

@probonopd
Copy link

probonopd commented Jan 13, 2021

The user has to know if escaping is needed and do escape, what he/she need to escape.

No, the user just wants to do drag and drop and it should "just work", as it does with other terminal emulator applciations.

By quoting paths dropped onto QTerminal things would become much smoother.
Other terminal applications would just automatically put single quotes around the paths in this situation:

Peek.2021-01-13.02-56.mp4

(QTerminal 0.15.0 on FreeBSD)

@probonopd
Copy link

Turns out that the fix is rather straightforward and does not need to introduce new dependencies:

fixed.mp4

probonopd added a commit to probonopd/qtermwidget that referenced this issue Mar 18, 2021
Allows drag-and-drop of files and directories that have spaces in their paths
Closes lxqt/qterminal#474
probonopd added a commit to probonopd/qtermwidget that referenced this issue Mar 18, 2021
Allows drag-and-drop of files and directories that have spaces in their paths
Closes lxqt/qterminal#474
Issues automation moved this from Sprint qterm* to Closed Jun 7, 2021
yan12125 pushed a commit to lxqt/qtermwidget that referenced this issue Jun 7, 2021
* Quote drag-and-drop filenames

Allows drag-and-drop of files and directories that have spaces in their paths
Closes lxqt/qterminal#474

* Correctly quote files with quotes in the filename
@probonopd
Copy link

Thank you very much @yan12125

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Issues
  
Closed
Issues
  
To do
7 participants