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>
(cherry picked from commit 90bf877604)
r14.0.x
Michele Calgaro 3 years ago
parent bde06503d5
commit 93f672a4c1
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -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 )

Loading…
Cancel
Save