https://bugs.kde.org/show_bug.cgi?id=388626

            Bug ID: 388626
           Summary: listFolder() in kio_obexftp handles trailing slashes
                    in url incorrectly when filling m_statMap
           Product: Bluedevil
           Version: 5.11.5
          Platform: openSUSE RPMs
                OS: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: NOR
         Component: kio-obex
          Assignee: now...@gmail.com
          Reporter: a425...@arcor.de
  Target Milestone: ---

Overview:
After opening a link to an obexftp directory on a phone in dolphin, pasting a
file into that directory fails.
Example url: obexftp://00-25-d0-xx-xx-xx/Speicherk./some/directory
Seems to be related to a problem in trailing-slash handling in kioobexftp.cpp
The problem surfaced recently while it was running ok before. I did not dig
into why it was covered before (I guess something in dolphin changed).

Steps to Reproduce:
enter e.g. in bash:
dolphin obexftp://00-25-d0-xx-xx-xx/Speicherk./some/directory
paste a file already in clipboard into that directory (Ctrl+V)

Actual Results: 
File does not appear in dolphin GUI in the directory.
syslog shows: e.g.  
obexd[4459]: Transfer(0x563b14ca3c10) Error: Forbidden
Pasted file is also not on the phone.

Expected Results:
File should appear in directory (in dolphin GUI and on phone).

Build Date & Platform:
NAME="openSUSE Tumbleweed"
VERSION="20180103 "
bluedevil5-5.11.5-1.1.x86_64.rpm

Additional Information:
Debugging result:
(bluedevil-5.11.5/src/kio/obexftp/kioobexftp.cpp)
The problem is caused by a failing stat() on the opened directory. This caused
by having a duplicate slash in m_statMap
(obexftp://00-25-d0-xx-xx-xx/Speicherk./some//directory).
Short debugging run-thru:
statHelper() is called for
"obexftp://00-25-d0-xx-xx-xx/Speicherk./some/directory";
It is not found in m_statMap so a
listFolder(urlUpDir(url), &ok);
is triggered to collect the missing information.
urlUpDir(url) results in "obexftp://00-25-d0-xx-xx-xx/Speicherk./some/";

Within listFolder() for each found directory entry

L464: QUrl statUrl = url;
L465: statUrl.setPath(statUrl.path() + QLatin1Char('/') + item.name());

is called. Results e.g. in
"obexftp://00-25-d0-xx-xx-xx/Speicherk./some//directory";.

Returned to statHelper() m_statMap does still not contain a result for
"obexftp://00-25-d0-xx-xx-xx/Speicherk./some//directory";.

So 
L416:  qCWarning(OBEXFTP) << "statMap still does not contains the url!";
is hit. statHelper() returns its result via
L419: statEntry(m_statMap.value(url.toDisplayString()));
... which is empty.

Proposed fix:
change L465 from
 statUrl.setPath(statUrl.path() + QLatin1Char('/') + item.name());
to
 if (statUrl.path().endsWith('/')) {
            statUrl.setPath(statUrl.path() + item.name());
        } else {
            statUrl.setPath(statUrl.path() + QLatin1Char('/') + item.name());
        }

This is e.g. in line with addPathToUrl() in
kio-5.40.0/src/core/copyjob.cpp

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to