Collapse double slashes in URLs regardless of Qt version

This commit is contained in:
Alessandro Pasotti 2019-12-09 15:57:46 +01:00
parent ac958dec89
commit 473a807922

View File

@ -69,17 +69,13 @@ void QgsServerOgcApi::registerHandler( QgsServerOgcApiHandler *handler )
QUrl QgsServerOgcApi::sanitizeUrl( const QUrl &url )
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
// Since QT 13 NormalizePathSegments does not collapse double slashes
// Since QT 5.12 NormalizePathSegments does not collapse double slashes
QUrl u { url.adjusted( QUrl::StripTrailingSlash | QUrl::NormalizePathSegments ) };
while ( u.path().contains( QLatin1String( "//" ) ) )
if ( u.path().contains( QLatin1String( "//" ) ) )
{
u.setPath( u.path().replace( QLatin1String( "//" ), QChar( '/' ) ) );
}
return u;
#else
return url.adjusted( QUrl::StripTrailingSlash | QUrl::NormalizePathSegments );
#endif
}
void QgsServerOgcApi::executeRequest( const QgsServerApiContext &context ) const