mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kio: handle non-local URLs in KRecentDocument and reject URLs with empty filename
this is mostly for KIO jobs that, for example, get remote URLs Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
3be77d2b5f
commit
f53d175e6b
1 changed files with 13 additions and 3 deletions
|
@ -104,9 +104,19 @@ void KRecentDocument::add(const KUrl &url, const QString &desktopEntryName)
|
|||
}
|
||||
|
||||
const QString path = recentDocumentDirectory();
|
||||
const QString fileName = url.fileName();
|
||||
QString fileName = url.fileName();
|
||||
if (!url.isLocalFile() && fileName.isEmpty()) {
|
||||
// remote URL may not include a filename. maight be just a protocol and host
|
||||
fileName = url.host();
|
||||
}
|
||||
if (fileName.isEmpty()) {
|
||||
// if the filename is empty then there is a problem
|
||||
kWarning(s_krecentdocumentarea) << "empty name" << url << "for" << desktopEntryName;
|
||||
return;
|
||||
}
|
||||
|
||||
// don't create a file called ".desktop", it will lead to an empty name in kio_recentdocuments
|
||||
const QString dStr = path + (fileName.isEmpty() ? QString("unnamed") : fileName);
|
||||
const QString dStr = path + fileName;
|
||||
|
||||
QString ddesktop = dStr + QLatin1String(".desktop");
|
||||
|
||||
|
@ -152,7 +162,7 @@ void KRecentDocument::add(const KUrl &url, const QString &desktopEntryName)
|
|||
conf.writePathEntry("URL", openStr );
|
||||
// If you change the line below, change the test in the above loop
|
||||
conf.writeEntry("X-KDE-LastOpenedWith", desktopEntryName);
|
||||
conf.writeEntry("Name", url.fileName());
|
||||
conf.writeEntry("Name", fileName);
|
||||
conf.writeEntry("Icon", KMimeType::iconNameForUrl(url));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue