CarterLi / iina

The modern video player for macOS with additional features and bug fixes.
https://iina.io
GNU General Public License v3.0
678 stars 29 forks source link

FTP links not working properly #37

Open halpz opened 2 years ago

halpz commented 2 years ago

when trying to open a file on my FTP server where there are filenames / directories with whitespace or square brackets, the stream fails to open.

SFTP doesnt work at all

i am pasting the link using shift+cmd+O and here are a list of example links (personal info changed:)

Links that work:

ftp://username:password@185.22.165.198/files/Vice.Principals.S01/Vice.Principals.S01E03.The.Field.Trip.1080p.AMZN.WEB-DL.DD.5.1.H.265-SiGMA.mkv

ftp://username:password@185.22.165.198/files/Beef.House.S01/Beef.House.S01E02.1080p.AMZN.WEB-DL.DD5.1.H.264-NBE.mkv

ftp://username:password@185.22.165.198/files/The.Castle.1997.1080p.BluRay.x264.DTS-FGT/The.Castle.1997.1080p.BluRay.x264.DTS-FGT.mkv

ftp://username:password@185.22.165.198/files/ren_and_stimpy_show/Series4/4e05b-Hard_Day's_Luck.mkv

links that dont work:

ftp://username:password@185.22.165.198/files/Eric_Andre_Show/The.Eric.Andre.Show.S05E02.1080p.WEB.h264-BAE[rarbg]/The.Eric.Andre.Show.S05E02.1080p.WEB.h264-BAE.mkv

ftp://username:password@185.22.165.198/files/Eric_Andre_Show/The.Eric.Andre.Show.S05E03.You.Got.Served.1080p.WEB-DL.DD5.1.H264-BTN[rarbg]/The.Eric.Andre.Show.S05E03.You.Got.Served.1080p.iT.WEB-DL.DD5.1.H264-BTN.mkv

ftp://username:password@185.22.165.198/files/ren_and_stimpy_show/Series%203/3e03a-Ren's_Pecs.mkv
CarterLi commented 2 years ago

I guess [ and ] should be URI encoded.

Try

ftp://username:password@185.22.165.198/files/Eric_Andre_Show/The.Eric.Andre.Show.S05E02.1080p.WEB.h264-BAE%5Brarbg%5D/The.Eric.Andre.Show.S05E02.1080p.WEB.h264-BAE.mkv
halpz commented 2 years ago

i was bringing it up as this works in infuse and vlc - and I looked at the code and it should be escaping the strings anyway, but doesnt seem to work still:

in OpenURLWindowController.swift :

guard var urlValue = trimmedUrlString.addingPercentEncoding(withAllowedCharacters: .urlAllowed) else {
      return (nil, false)
    }
halpz commented 2 years ago

i would test changes, but I cant get the project to build in xcode

CarterLi commented 2 years ago

They must be encoded separately. For example % in Series%203, you can't know whether it has been encoded or not. With withAllowedCharacters: .urlAllowed, they will be always preserved.