summaryrefslogtreecommitdiffstats
path: root/tdeio
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2020-12-31 15:16:46 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2020-12-31 18:53:45 +0900
commit90bf87760453c5fb32e6b135dfcfadc2d7700886 (patch)
tree960b6cd8693094699ad019b57b1983aabfa22a32 /tdeio
parent9468d05e3d2c56d4287ef464a31f21a689ad7e14 (diff)
downloadtdelibs-90bf87760453c5fb32e6b135dfcfadc2d7700886.tar.gz
tdelibs-90bf87760453c5fb32e6b135dfcfadc2d7700886.zip
Fixed handling of files containing an # in the name when using the system:/media or media:/ protocol. This resolves bug 3022 and bug 3063.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'tdeio')
-rw-r--r--tdeio/tdeio/kdirlister.cpp83
1 files changed, 40 insertions, 43 deletions
diff --git a/tdeio/tdeio/kdirlister.cpp b/tdeio/tdeio/kdirlister.cpp
index 1f3a03d1d..7b564f337 100644
--- a/tdeio/tdeio/kdirlister.cpp
+++ b/tdeio/tdeio/kdirlister.cpp
@@ -2355,25 +2355,24 @@ void KDirLister::handleError( TDEIO::Job *job )
void KDirLister::addNewItem( const KFileItem *item )
{
- if ( ( d->dirOnlyMode && !item->isDir() ) || !matchesFilter( item ) ) {
- return; // No reason to continue... bailing out here prevents a mimetype scan.
- }
-
- if ((item->url().internalReferenceURL() != "")
- && (d->m_referenceURLMap.contains(item->url().internalReferenceURL()))) {
+ TQString refURL = item->url().internalReferenceURL();
+ if (!refURL.isEmpty() && d->m_referenceURLMap.contains(refURL) &&
+ item->url().path().startsWith(d->m_referenceURLMap[refURL]))
+ {
// Likely a media:/ tdeioslave URL or similar
// Rewrite the URL to ensure that the user remains within the media:/ tree!
- TQString itemPath = item->url().path();
- if (itemPath.startsWith(d->m_referenceURLMap[item->url().internalReferenceURL()])) {
- itemPath = itemPath.remove(0, d->m_referenceURLMap[item->url().internalReferenceURL()].length());
- TQString newPath = item->url().internalReferenceURL();
- if (!newPath.endsWith("/")) newPath = newPath + "/";
- while (itemPath.startsWith("/")) itemPath = itemPath.remove(0,1);
- while (itemPath.endsWith("/")) itemPath.truncate(itemPath.length()-1);
- newPath = newPath + itemPath;
- const_cast<KFileItem*>(item)->setListerURL(item->url());
- const_cast<KFileItem*>(item)->setURL(newPath);
+ if (!refURL.endsWith("/"))
+ {
+ refURL.append("/");
}
+ KURL newItemURL(refURL);
+ newItemURL.addPath(item->url().fileName());
+ const_cast<KFileItem*>(item)->setListerURL(newItemURL);
+ const_cast<KFileItem*>(item)->setURL(newItemURL);
+ }
+
+ if ( ( d->dirOnlyMode && !item->isDir() ) || !matchesFilter( item ) ) {
+ return; // No reason to continue... bailing out here prevents a mimetype scan.
}
if ( matchesMimeFilter( item ) )
@@ -2420,21 +2419,20 @@ void KDirLister::addRefreshItem( const KFileItem *item )
{
bool isExcluded = (d->dirOnlyMode && !item->isDir()) || !matchesFilter( item );
- if ((item->url().internalReferenceURL() != "")
- && (d->m_referenceURLMap.contains(item->url().internalReferenceURL()))) {
+ TQString refURL = item->url().internalReferenceURL();
+ if (!refURL.isEmpty() && d->m_referenceURLMap.contains(refURL) &&
+ item->url().path().startsWith(d->m_referenceURLMap[refURL]))
+ {
// Likely a media:/ tdeioslave URL or similar
// Rewrite the URL to ensure that the user remains within the media:/ tree!
- TQString itemPath = item->url().path();
- if (itemPath.startsWith(d->m_referenceURLMap[item->url().internalReferenceURL()])) {
- itemPath = itemPath.remove(0, d->m_referenceURLMap[item->url().internalReferenceURL()].length());
- TQString newPath = item->url().internalReferenceURL();
- if (!newPath.endsWith("/")) newPath = newPath + "/";
- while (itemPath.startsWith("/")) itemPath = itemPath.remove(0,1);
- while (itemPath.endsWith("/")) itemPath.truncate(itemPath.length()-1);
- newPath = newPath + itemPath;
- const_cast<KFileItem*>(item)->setListerURL(item->url());
- const_cast<KFileItem*>(item)->setURL(newPath);
+ if (!refURL.endsWith("/"))
+ {
+ refURL.append("/");
}
+ KURL newItemURL(refURL);
+ newItemURL.addPath(item->url().fileName());
+ const_cast<KFileItem*>(item)->setListerURL(newItemURL);
+ const_cast<KFileItem*>(item)->setURL(newItemURL);
}
if ( !isExcluded && matchesMimeFilter( item ) )
@@ -2658,25 +2656,24 @@ void KDirLister::connectJob( TDEIO::ListJob *job )
void KDirLister::emitCompleted( const KURL& _url )
{
- KURL emitURL = _url;
-
- if ((_url.internalReferenceURL() != "")
- && (d->m_referenceURLMap.contains(_url.internalReferenceURL()))) {
+ TQString refURL = _url.internalReferenceURL();
+ if (!refURL.isEmpty() && d->m_referenceURLMap.contains(refURL) &&
+ _url.path().startsWith(d->m_referenceURLMap[refURL]))
+ {
// Likely a media:/ tdeioslave URL or similar
// Rewrite the URL to ensure that the user remains within the media:/ tree!
- TQString itemPath = _url.path();
- if (itemPath.startsWith(d->m_referenceURLMap[_url.internalReferenceURL()])) {
- itemPath = itemPath.remove(0, d->m_referenceURLMap[_url.internalReferenceURL()].length());
- TQString newPath = _url.internalReferenceURL();
- if (!newPath.endsWith("/")) newPath = newPath + "/";
- while (itemPath.startsWith("/")) itemPath = itemPath.remove(0,1);
- while (itemPath.endsWith("/")) itemPath.truncate(itemPath.length()-1);
- newPath = newPath + itemPath;
- emitURL = newPath;
+ if (!refURL.endsWith("/"))
+ {
+ refURL.append("/");
}
+ KURL newItemURL(refURL);
+ newItemURL.addPath(_url.fileName());
+ emit completed(newItemURL);
+ }
+ else
+ {
+ emit completed(_url);
}
-
- emit completed( emitURL );
}
void KDirLister::setMainWindow( TQWidget *window )