Bug 300988 - Cannot change directory on FTP connection with AIX server
Summary: Cannot change directory on FTP connection with AIX server
Status: RESOLVED FIXED
Alias: None
Product: kio
Classification: Frameworks and Libraries
Component: ftp (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR major
Target Milestone: ---
Assignee: David Faure
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-01 10:00 UTC by gyszalai
Modified: 2013-10-25 06:36 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.9.3


Attachments
screen shot identifying names with spaces at the beginning. (384.08 KB, image/jpeg)
2012-07-17 09:05 UTC, Patryk Benderz
Details
patch v1 (2.48 KB, text/x-patch)
2012-09-28 23:56 UTC, Dawit Alemayehu
Details
patch v2 (2.53 KB, patch)
2012-09-29 06:24 UTC, Dawit Alemayehu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description gyszalai 2012-06-01 10:00:01 UTC
If I connect to an AIX server with FTP, I'm unable to change directories by ENTER or the cursor keys. I always get the following error: "Error: Could not enter folder: <foldername>". After some investigation, I realized this is because there is a space character between end of the current location and the name of the directory that I'd like to change to. 

For example: let's assume that the current location is /usr and I'd like to change to /usr/lib.
The error message I get is: "Error: Could not enter folder: /usr/ lib" note the space character before "lib".

I use Krusader 2.4.0-beta1 with KDE 4.8.2 on Ubuntu 12.04.
Passive mode is enabled in KDE system settings.


Reproducible: Always

Steps to Reproduce:
1. Connect to an AIX FTP server
2. Try changing to any directory

Actual Results:  
Error: Could not enter folder: <foldername>

Expected Results:  
Change to the desired folder

The server runs AIX 5.2 PPC (64bit)
Comment 1 Jan Lepper 2012-06-01 10:34:24 UTC
Does this happen only with Krusader, not Konqueror/Dolphin/other ftp clients ?
Comment 2 gyszalai 2012-06-01 11:40:55 UTC
Yes, it happens with Konqueror as well.
Comment 3 gyszalai 2012-06-01 11:47:35 UTC
By the way, it doesn't happen if I use sftp protocol instead of ftp.
Comment 4 Patryk Benderz 2012-06-08 14:53:57 UTC
Hi,
I have tested this on Ubuntu 12.04, with Krusader 2.4.0-beta1 and can confirm this behaviour. This bug happens also with AIX 5.3.0.0 and 6.1.0.0 as FTp server. As a sidenote, this bug also happens with MidnightCommander. Other FTP clients seem to work fine.
Current status indicates that you need info. Please specify what exactly do you need, cause I really like Krusader and use it as everyday tool in my work. Lack of FTP connectiont paralyzes my work. What can I do to help you resolve this bug?
Comment 5 Patryk Benderz 2012-07-17 08:58:47 UTC
Recently nothing was happening around this bug, so I investigated it a bit and have noticed following relation. The files with additional space in name are ONLY the ones, which have NOT been modified at current day. In such cases the 'hh:mm' part of modification date is replaced by 'YYYY ' followed by additional space, which makes krusader to add one additional space to file name.
I am attaching screen shot, illustrating this situation:
Bug_300988_Cannot_change_directory_on_FTP_connection_with_AIX_server.png
Comment 6 Patryk Benderz 2012-07-17 09:05:41 UTC
Created attachment 72579 [details]
screen shot identifying names with spaces at the beginning.
Comment 7 Jan Lepper 2012-09-24 19:13:56 UTC
Apparently this happens because the fix for https://bugs.kde.org/show_bug.cgi?id=88575 (Do not trim whitespaces from filenames.)
Comment 8 Dawit Alemayehu 2012-09-28 23:55:03 UTC
(In reply to comment #7)
> Apparently this happens because the fix for
> https://bugs.kde.org/show_bug.cgi?id=88575 (Do not trim whitespaces from
> filenames.)

Well, since I am responsible for that fix, I looked into this and came up with a potential fix. However, I do not have access to an ftp server on a AIX machine and as such no means to test the patch. Can any of you either test the patch (you have to compile kdelibs 4.9 branch from source) or provide a test ftp server on an AIX box ?
Comment 9 Dawit Alemayehu 2012-09-28 23:56:40 UTC
Created attachment 74220 [details]
patch v1
Comment 10 Dawit Alemayehu 2012-09-28 23:57:53 UTC
Comment on attachment 74220 [details]
patch v1

>diff --git a/kioslave/ftp/ftp.cpp b/kioslave/ftp/ftp.cpp
>index 26be283..6e2fdae 100644
>--- a/kioslave/ftp/ftp.cpp
>+++ b/kioslave/ftp/ftp.cpp
>@@ -1465,6 +1465,7 @@ void Ftp::stat(const KUrl &url)
>   FtpEntry  ftpEnt;
>   while( ftpReadDir(ftpEnt) )
>   {
>+    fixupEntryName(&ftpEnt);
>     // We look for search or filename, since some servers (e.g. ftp.tuwien.ac.at)
>     // return only the filename when doing "dir /full/path/to/file"
>     if (!bFound) {
>@@ -1548,6 +1549,7 @@ void Ftp::listDir( const KUrl &url )
>   FtpEntry  ftpEnt;
>   while( ftpReadDir(ftpEnt) )
>   {
>+    fixupEntryName(&ftpEnt);
>     //kDebug(7102) << ftpEnt.name;
>     //Q_ASSERT( !ftpEnt.name.isEmpty() );
>     if ( !ftpEnt.name.isEmpty() )
>@@ -2607,3 +2609,38 @@ void Ftp::saveProxyAuthentication()
>     delete m_socketProxyAuth;
>     m_socketProxyAuth = 0;
> }
>+
>+void Ftp::fixupEntryName(FtpEntry* e)
>+{
>+    Q_ASSERT(e);
>+    if (!e->name.startsWith(QLatin1Char(' ')))
>+        return;
>+
>+    if (e->type == S_IFDIR) {
>+        if (!ftpFolder(e->name, false)) {
>+            // whitespaces in directory name are bogus...
>+            int index = 0;
>+            while (e->name.at(index) == QLatin1Char(' ')) {
>+                index++;
>+                const QString name (e->name.mid(index));
>+                if (ftpFolder(name, false)) {
>+                    kDebug(7102) << "fixing up directory name from" << e->name << "to" << name;
>+                    e->name = name;
>+                }
>+            }
>+        }
>+    } else {
>+        if (!ftpFileExists(e->name)) {
>+            // whitespaces in directory name are bogus...
>+            int index = 0;
>+            while (e->name.at(index) == QLatin1Char(' ')) {
>+                index++;
>+                const QString name (e->name.mid(index));
>+                if (ftpFileExists(name)) {
>+                    kDebug(7102) << "fixing up filename from" << e->name << "to" << name;
>+                    e->name = name;
>+                }
>+            }
>+        }
>+    }
>+}
>diff --git a/kioslave/ftp/ftp.h b/kioslave/ftp/ftp.h
>index 2465a4b..f5c3ec1 100644
>--- a/kioslave/ftp/ftp.h
>+++ b/kioslave/ftp/ftp.h
>@@ -333,6 +333,12 @@ private:
>    */
>   StatusCode ftpSendMimeType(int& iError, const KUrl& url);
> 
>+  /**
>+   * Fixes up an entry name so that extraneous whitespaces do not cause
>+   * problems. See bug# 88575 and bug# 300988.
>+   */
>+  void fixupEntryName(FtpEntry*);
>+
> private Q_SLOTS:
>   void proxyAuthentication(const QNetworkProxy&, QAuthenticator*);
>   void saveProxyAuthentication();
Comment 11 Dawit Alemayehu 2012-09-29 06:24:47 UTC
Created attachment 74224 [details]
patch v2
Comment 12 Dawit Alemayehu 2012-10-18 14:48:18 UTC
Git commit 014e8f3ca18b0dd22e041f9785afc578f1ebc51b by Dawit Alemayehu.
Committed on 29/09/2012 at 08:24.
Pushed by adawit into branch 'KDE/4.9'.

Make sure bogus whitespaces do not break listing.

This patch addresses the regression caused by the fix for bug# 88575. Namely
not trimming the white spaces from filenames breaks AIX ftp servers which
seem to add bogus whitespace between the date and entry name.
FIXED-IN:4.9.3
REVIEW:106636

M  +89   -17   kioslave/ftp/ftp.cpp
M  +12   -1    kioslave/ftp/ftp.h

http://commits.kde.org/kdelibs/014e8f3ca18b0dd22e041f9785afc578f1ebc51b
Comment 13 Patryk Benderz 2013-10-24 08:09:19 UTC
Hello Dawit,
Is this patch already in some packaged version I could install? i am asking because Ubunu team seems to not care much about Krusader - there is still 2.4.0-beta1 in Ubuntu 13.04.
Comment 14 Dawit Alemayehu 2013-10-25 02:25:07 UTC
(In reply to comment #13)
> Hello Dawit,
> Is this patch already in some packaged version I could install? i am asking
> because Ubunu team seems to not care much about Krusader - there is still
> 2.4.0-beta1 in Ubuntu 13.04.

It is not the Krusader version that matters for this patch. It is the kdelibs version. If it is equal to or greater than 4.9.3, then this patch should already be included.
Comment 15 Patryk Benderz 2013-10-25 06:36:53 UTC
(In reply to comment #14)
> It is not the Krusader version that matters for this patch. It is the
> kdelibs version. If it is equal to or greater than 4.9.3, then this patch
> should already be included.

$ apt-cache policy kdelibs*
[...]
kdelibs-bin:
  Installed:      4:4.10.5-0ubuntu0.1
  Candidate:   4:4.10.5-0ubuntu0.1
[...]

So it seems 4.10.5>4.9.3, but I still am unable to use Krusader with AIX FTP. Any clue?