Bug 326292

Summary: KIO FTP slave failed to access files on swiftp FTP server(http://ppareit.github.io/swiftp/ )
Product: [Unmaintained] kio Reporter: V字龍(Vdragon) <Vdragon.Taiwan>
Component: ftpAssignee: David Faure <faure>
Status: RESOLVED FIXED    
Severity: normal CC: aacid, adawit, fabiodurso
Priority: NOR    
Version: 4.10.5   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In: 4.12.4
Sentry Crash Report:

Description V字龍(Vdragon) 2013-10-19 20:14:54 UTC
As summary, I failed to open some EPUB document on FTP server with okular.

The content of the error dialog:
Could not open ftp://Vdragon@192.168.128.6:12345/Books/MoonReader/IN THE YEAR 2889.epub. Reason: Could not read file ftp://Vdragon@192.168.128.6:12345/Books/MoonReader/IN%20THE%20YEAR%202889.epub.

Reproducible: Always
Comment 1 Fabio D'Urso 2013-10-19 23:17:27 UTC
Hi, can you reproduce the issue on some publicly accessible server?
How are you opening the file? ("open file" dialog, dolphin, konqueror, command line, ...)
I can open remote FTP files here.
Comment 2 Albert Astals Cid 2013-10-20 16:17:34 UTC
Waiting for info
Comment 3 V字龍(Vdragon) 2013-10-20 16:27:15 UTC
@Fabio D'Urso
I can't reproduce this issue on a standard FTP server.

I tried to open file from Dolphin FM and from the "open file" dialog of Okular itself.

The FTP server I met issue with is an Android application from the following site
https://github.com/ppareit/swiftp
which seems to lack certain functionalities(FTP commands?) than other alternatives.  So maybe this issue is actually related to FTP KIO slave.

From my perspective I'm expecting a more detailed error message to appear instead of "We can't read that file.".
Comment 4 Albert Astals Cid 2013-10-20 16:37:17 UTC
Seriously? What kind of more detailed error are you expecting?
Comment 5 V字龍(Vdragon) 2013-10-20 17:02:08 UTC
@ Albert Astals Cid 
Like "Remote server didn't support XXXX command", something FTP KIO slave should(?) know about.
Currently the error message is much like "Could not open <file>.  Reason: Could not open <file>" to me.

More info about the issue:
* I can normally transfer files using GNOME Nautilus FM and FileZilla FTP client
* On Dolphin FM, copying files from swiftp server to local storage produces .part(however the content seems to be the same as in the remote) files in local with "transfer failed" error dialogs
* On Okular, opening files from remote server(whether from Dolphin or from Okular itself) fails
* kdelibs version on my system is 4.10.5, which is from Ubuntu 13.04 repository.

Since the problem is more likely on KIO-ftp(which seems to be provided by kdelibs) I've changed the affected product.
Comment 6 Dawit Alemayehu 2014-03-01 21:25:43 UTC
I installed a demo version of this ftp server and it does not support the RETR command which causes kio_ftp to fail with ERR_CANNOT_OPEN_FOR_READING error in Ftp::ftpGet. It has no problem listing the contents returned by the ftp server.
Comment 7 Dawit Alemayehu 2014-03-01 23:10:15 UTC
(In reply to comment #6)
> I installed a demo version of this ftp server and it does not support the
> RETR command which causes kio_ftp to fail with ERR_CANNOT_OPEN_FOR_READING
> error in Ftp::ftpGet. It has no problem listing the contents returned by the
> ftp server.

Correction actually that is not the problem. Apparently, that is only returned when you do not have access to the file. The real problem with viewing files you do have access to is the code that checks for file size:

kio_ftp(31275) Ftp::ftpSendCmd: send>  SIZE /ueventd.rc
kio_ftp(31275) Ftp::ftpResponse:         >  550 No directory traversal allowed in SIZE param
kio_ftp(31275) Ftp::ftpResponse: resp >  550 No directory traversal allowed in SIZE param

Apparently the server does not allow you to use full file path to do SIZE requests. I think this is probably something we can address.
Comment 8 Dawit Alemayehu 2014-03-02 06:10:04 UTC
Proposed fix https://git.reviewboard.kde.org/r/116524/
Comment 9 Dawit Alemayehu 2014-03-02 06:10:19 UTC
Proposed fix https://git.reviewboard.kde.org/r/116524/
Comment 10 Dawit Alemayehu 2014-03-13 05:05:12 UTC
Git commit d6453435f0d475e16b2512782b9b3e40bb603da1 by Dawit Alemayehu.
Committed on 01/03/2014 at 23:39.
Pushed by adawit into branch 'KDE/4.12'.

Whenever possible, use relative paths for SIZE requests, e.g. SIZE foo/bar.txt
FIXED-IN: 4.12.4
REVIEW: 116524

M  +16   -3    kioslave/ftp/ftp.cpp

http://commits.kde.org/kdelibs/d6453435f0d475e16b2512782b9b3e40bb603da1