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

seems dragfile can't handle filename contains ' or space ? #57

Open
yurenchen000 opened this issue Sep 17, 2024 · 6 comments
Open

seems dragfile can't handle filename contains ' or space ? #57

yurenchen000 opened this issue Sep 17, 2024 · 6 comments

Comments

@yurenchen000
Copy link

yurenchen000 commented Sep 17, 2024

on linux, if a file path is /tmp/12' 3'
it seems not safe to encode/decode with current scheme?

https://github.com/trzsz/trzsz-go/blob/5622a20/trzsz/drag.go#L73
//I noticed the drag detect logic when I try to adapting to a vte-based terminal (terminator or gnome-terminal)

@lonnywong
Copy link
Member

On Linux, if the path contains spaces, the dragged path will be similar to '/tmp/12 3'

@yurenchen000
Copy link
Author

On Linux, if the path contains spaces, the dragged path will be similar to '/tmp/12 3'

if the file is /tmp/12' 3 (contains both space and ')
current parser may not work

@lonnywong
Copy link
Member

Which Linux and Terminal would be like this? We only deal with real issues, not imaginary ones.

@yurenchen000
Copy link
Author

it's

  • warp-terminal_0.2024.09.10.08.02.stable
  • trzsz-go 5622a20 v1.1.8
    //I add debug print to stderr ( trzsz go 1.1.8 offical release binary got the same result)
  • ubuntu 22.04.4 LTS, X11 windowing

trzsz_drag_warp1-


test files (one file at a time):

  • /run/test/temp/12 3 failed
  • /run/test/temp/12 3' failed
  • /run/test/temp/123 success

@lonnywong
Copy link
Member

Maybe https://github.com/google/shlex can support it.

@yurenchen000
Copy link
Author

Maybe https://github.com/google/shlex can support it.

Agree.
I think it follows shell quoting when drag files to warp terminal
(only tested with warp 0.2024.09.10.08.02.stable, ubuntu 22)

shlex.Split() do it well


Test code:

// string got from warp terminal when drag files
str := `/run/test/temp/22\ 3 /run/test/temp/32\ 3\' /run/test/temp/123`

// try to split and decode it
arr, err := shlex.Split(str)

fmt.Println("s1:", str)
fmt.Printf("ss: %#v\n", arr)

Result is as expected.

s1: /run/test/temp/22\ 3 /run/test/temp/32\ 3\' /run/test/temp/123
ss: []string{"/run/test/temp/22 3", "/run/test/temp/32 3'", "/run/test/temp/123"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants