Skip to content

Commit

Permalink
Use proper API to hide .aux.xml, .shp.xml and .tif.xml files from bro…
Browse files Browse the repository at this point in the history
…wser

instead of hardcoded lists
  • Loading branch information
nyalldawson committed Nov 5, 2020
1 parent 04dc5f5 commit 67e1a80
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 26 deletions.
17 changes: 4 additions & 13 deletions src/core/providers/gdal/qgsgdaldataitems.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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 ) )
Expand Down
17 changes: 4 additions & 13 deletions src/core/providers/ogr/qgsogrdataitems.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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 ) )
Expand Down

0 comments on commit 67e1a80

Please sign in to comment.