Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit b3bfa11a authored by Grégory Oestreicher's avatar Grégory Oestreicher

Pre-validation of the collections propfind response

Not sure if this may explain the disappearing collections in some cases
but here goes. Extra validation can't hurt.

CCBUG: 341998
parent 44d38d36
......@@ -141,7 +141,14 @@ void DavCollectionsFetchJob::collectionsFetchFinished( KJob *job )
_jobUrl.setUser( QString() );
const QString jobUrl = _jobUrl.prettyUrl();
//kDebug() << davJob->response().toString();
// Validate that we got a valid PROPFIND response
QDomElement rootElement = davJob->response().documentElement();
if ( rootElement.tagName().compare( QLatin1String( "multistatus" ), Qt::CaseInsensitive ) != 0 ) {
setError( UserDefinedError );
setErrorText( i18n( "Invalid responses from backend" ) );
subjobFinished();
return;
}
QByteArray resp( davJob->response().toByteArray() );
QBuffer buffer( &resp );
......@@ -151,12 +158,16 @@ void DavCollectionsFetchJob::collectionsFetchFinished( KJob *job )
if ( !xquery.setFocus( &buffer ) ) {
setError( UserDefinedError );
setErrorText( i18n( "Error setting focus for XQuery" ) );
subjobFinished();
return;
}
xquery.setQuery( DavManager::self()->davProtocol( mUrl.protocol() )->collectionsXQuery() );
if ( !xquery.isValid() ) {
setError( UserDefinedError );
setErrorText( i18n( "Invalid XQuery submitted by DAV implementation" ) );
subjobFinished();
return;
}
QString responsesStr;
......@@ -168,6 +179,8 @@ void DavCollectionsFetchJob::collectionsFetchFinished( KJob *job )
if ( !document.setContent( responsesStr, true ) ) {
setError( UserDefinedError );
setErrorText( i18n( "Invalid responses from backend" ) );
subjobFinished();
return;
}
if ( !error() ) {
......@@ -301,6 +314,11 @@ void DavCollectionsFetchJob::collectionsFetchFinished( KJob *job )
}
}
subjobFinished();
}
void DavCollectionsFetchJob::subjobFinished()
{
if ( --mSubJobCount == 0 )
emitResult();
}
......
......@@ -73,6 +73,7 @@ class DavCollectionsFetchJob : public KJob
private:
void doCollectionsFetch( const KUrl &url );
void subjobFinished();
DavUtils::DavUrl mUrl;
DavCollection::List mCollections;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment