Skip to content
Permalink
Browse files

Use proper API to hide .aux.xml, .shp.xml and .tif.xml files from bro…

…wser

instead of hardcoded lists
  • Loading branch information
nyalldawson committed Nov 5, 2020
1 parent 04dc5f5 commit 67e1a8078da178a7a4ae64a0040522eaaeb965d3
Showing with 8 additions and 26 deletions.
  1. +4 −13 src/core/providers/gdal/qgsgdaldataitems.cpp
  2. +4 −13 src/core/providers/ogr/qgsogrdataitems.cpp
@@ -154,6 +154,10 @@ QgsDataItem *QgsGdalDataItemProvider::createDataItem( const QString &pathIn, Qgs
return nullptr;
}

// hide blocklisted URIs, such as .aux.xml files
if ( QgsProviderRegistry::instance()->uriIsBlocklisted( path ) )
return nullptr;

QgsDebugMsgLevel( "thePath = " + path, 2 );

// zip settings + info
@@ -220,19 +224,6 @@ QgsDataItem *QgsGdalDataItemProvider::createDataItem( const QString &pathIn, Qgs
QgsDebugMsgLevel( QStringLiteral( "wildcards: " ) + sWildcards.join( ' ' ), 2 );
} );

// skip *.aux.xml files (GDAL auxiliary metadata files),
// *.shp.xml files (ESRI metadata) and *.tif.xml files (TIFF metadata)
// unless that extension is in the list (*.xml might be though)
if ( path.endsWith( QLatin1String( ".aux.xml" ), Qt::CaseInsensitive ) &&
!sExtensions.contains( QStringLiteral( "aux.xml" ) ) )
return nullptr;
if ( path.endsWith( QLatin1String( ".shp.xml" ), Qt::CaseInsensitive ) &&
!sExtensions.contains( QStringLiteral( "shp.xml" ) ) )
return nullptr;
if ( path.endsWith( QLatin1String( ".tif.xml" ), Qt::CaseInsensitive ) &&
!sExtensions.contains( QStringLiteral( "tif.xml" ) ) )
return nullptr;

// skip QGIS style xml files
if ( path.endsWith( QLatin1String( ".xml" ), Qt::CaseInsensitive ) &&
QgsStyle::isXmlStyleFile( path ) )
@@ -493,6 +493,10 @@ QgsDataItem *QgsOgrDataItemProvider::createDataItem( const QString &pathIn, QgsD
return nullptr;
}

// hide blocklisted URIs, such as .aux.xml files
if ( QgsProviderRegistry::instance()->uriIsBlocklisted( path ) )
return nullptr;

QgsDebugMsgLevel( "thePath: " + path, 2 );

// zip settings + info
@@ -556,19 +560,6 @@ QgsDataItem *QgsOgrDataItemProvider::createDataItem( const QString &pathIn, QgsD
if ( !isOgrSupportedDirectory && !info.isFile() && vsiPrefix.isEmpty() )
return nullptr;

// skip *.aux.xml files (GDAL auxiliary metadata files),
// *.shp.xml files (ESRI metadata) and *.tif.xml files (TIFF metadata)
// unless that extension is in the list (*.xml might be though)
if ( path.endsWith( QLatin1String( ".aux.xml" ), Qt::CaseInsensitive ) &&
!myExtensions.contains( QStringLiteral( "aux.xml" ) ) )
return nullptr;
if ( path.endsWith( QLatin1String( ".shp.xml" ), Qt::CaseInsensitive ) &&
!myExtensions.contains( QStringLiteral( "shp.xml" ) ) )
return nullptr;
if ( path.endsWith( QLatin1String( ".tif.xml" ), Qt::CaseInsensitive ) &&
!myExtensions.contains( QStringLiteral( "tif.xml" ) ) )
return nullptr;

// skip QGIS style xml files
if ( path.endsWith( QLatin1String( ".xml" ), Qt::CaseInsensitive ) &&
QgsStyle::isXmlStyleFile( path ) )

0 comments on commit 67e1a80

Please sign in to comment.
You can’t perform that action at this time.