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>
pull/115/head
Michele Calgaro 3 years ago
parent 9468d05e3d
commit 90bf877604
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -2355,25 +2355,24 @@ void KDirLister::handleError( TDEIO::Job *job )
void KDirLister::addNewItem( const KFileItem *item ) void KDirLister::addNewItem( const KFileItem *item )
{ {
if ( ( d->dirOnlyMode && !item->isDir() ) || !matchesFilter( item ) ) { TQString refURL = item->url().internalReferenceURL();
return; // No reason to continue... bailing out here prevents a mimetype scan. if (!refURL.isEmpty() && d->m_referenceURLMap.contains(refURL) &&
} item->url().path().startsWith(d->m_referenceURLMap[refURL]))
{
if ((item->url().internalReferenceURL() != "")
&& (d->m_referenceURLMap.contains(item->url().internalReferenceURL()))) {
// Likely a media:/ tdeioslave URL or similar // Likely a media:/ tdeioslave URL or similar
// Rewrite the URL to ensure that the user remains within the media:/ tree! // Rewrite the URL to ensure that the user remains within the media:/ tree!
TQString itemPath = item->url().path(); if (!refURL.endsWith("/"))
if (itemPath.startsWith(d->m_referenceURLMap[item->url().internalReferenceURL()])) { {
itemPath = itemPath.remove(0, d->m_referenceURLMap[item->url().internalReferenceURL()].length()); refURL.append("/");
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);
} }
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 ) ) if ( matchesMimeFilter( item ) )
@ -2420,21 +2419,20 @@ void KDirLister::addRefreshItem( const KFileItem *item )
{ {
bool isExcluded = (d->dirOnlyMode && !item->isDir()) || !matchesFilter( item ); bool isExcluded = (d->dirOnlyMode && !item->isDir()) || !matchesFilter( item );
if ((item->url().internalReferenceURL() != "") TQString refURL = item->url().internalReferenceURL();
&& (d->m_referenceURLMap.contains(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 // Likely a media:/ tdeioslave URL or similar
// Rewrite the URL to ensure that the user remains within the media:/ tree! // Rewrite the URL to ensure that the user remains within the media:/ tree!
TQString itemPath = item->url().path(); if (!refURL.endsWith("/"))
if (itemPath.startsWith(d->m_referenceURLMap[item->url().internalReferenceURL()])) { {
itemPath = itemPath.remove(0, d->m_referenceURLMap[item->url().internalReferenceURL()].length()); refURL.append("/");
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);
} }
KURL newItemURL(refURL);
newItemURL.addPath(item->url().fileName());
const_cast<KFileItem*>(item)->setListerURL(newItemURL);
const_cast<KFileItem*>(item)->setURL(newItemURL);
} }
if ( !isExcluded && matchesMimeFilter( item ) ) if ( !isExcluded && matchesMimeFilter( item ) )
@ -2658,25 +2656,24 @@ void KDirLister::connectJob( TDEIO::ListJob *job )
void KDirLister::emitCompleted( const KURL& _url ) void KDirLister::emitCompleted( const KURL& _url )
{ {
KURL emitURL = _url; TQString refURL = _url.internalReferenceURL();
if (!refURL.isEmpty() && d->m_referenceURLMap.contains(refURL) &&
if ((_url.internalReferenceURL() != "") _url.path().startsWith(d->m_referenceURLMap[refURL]))
&& (d->m_referenceURLMap.contains(_url.internalReferenceURL()))) { {
// Likely a media:/ tdeioslave URL or similar // Likely a media:/ tdeioslave URL or similar
// Rewrite the URL to ensure that the user remains within the media:/ tree! // Rewrite the URL to ensure that the user remains within the media:/ tree!
TQString itemPath = _url.path(); if (!refURL.endsWith("/"))
if (itemPath.startsWith(d->m_referenceURLMap[_url.internalReferenceURL()])) { {
itemPath = itemPath.remove(0, d->m_referenceURLMap[_url.internalReferenceURL()].length()); refURL.append("/");
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;
} }
KURL newItemURL(refURL);
newItemURL.addPath(_url.fileName());
emit completed(newItemURL);
}
else
{
emit completed(_url);
} }
emit completed( emitURL );
} }
void KDirLister::setMainWindow( TQWidget *window ) void KDirLister::setMainWindow( TQWidget *window )

Loading…
Cancel
Save