Parse drag data manually to avoid GetURIs crashes

This commit is contained in:
Stu 2025-12-13 22:46:46 -05:00
parent 20c4b5d177
commit 29bc1ac19c

View File

@ -5,6 +5,7 @@ import (
"log" "log"
"path/filepath" "path/filepath"
"time" "time"
"strings"
"git.leaktechnologies.dev/stu/VT_Player/player/mpvembed" "git.leaktechnologies.dev/stu/VT_Player/player/mpvembed"
@ -288,19 +289,28 @@ func setupDragDest(p *pane, win *gtk.Window) {
if data == nil { if data == nil {
return return
} }
var path string raw := data.GetData()
if uris := data.GetURIs(); len(uris) > 0 { if len(raw) == 0 {
path = uriToPath(uris[0]) // try text fallback
}
if path == "" {
if txt := data.GetText(); txt != "" { if txt := data.GetText(); txt != "" {
path = uriToPath(txt) raw = []byte(txt)
} }
} }
if path == "" { if len(raw) == 0 {
return return
} }
loadIntoPane(p, path) // text/uri-list: newline or CRLF separated
lines := strings.Split(string(raw), "\n")
for _, ln := range lines {
ln = strings.TrimSpace(ln)
if ln == "" {
continue
}
if path := uriToPath(ln); path != "" {
loadIntoPane(p, path)
break
}
}
}) })
} }