Skip to content

Commit

Permalink
Allow remote SVG files with text/plain MIME type, instead of only
Browse files Browse the repository at this point in the history
valid image/svg+xml mime types

This allows users to link to SVG files hosted on github, where
the raw content is served up as plain text.
  • Loading branch information
nyalldawson committed Mar 29, 2018
1 parent 50241dc commit d3aae3f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/core/symbology/qgssvgcache.cpp
Expand Up @@ -461,10 +461,13 @@ QByteArray QgsSvgCache::getImageData( const QString &path ) const
return mMissingSvg;
}

// we accept both real SVG mime types AND plain text types - because some sites
// (notably github) serve up svgs as raw text
QString contentType = reply->header( QNetworkRequest::ContentTypeHeader ).toString();
QgsDebugMsg( "contentType: " + contentType );
if ( !contentType.startsWith( QLatin1String( "image/svg+xml" ), Qt::CaseInsensitive ) )
if ( !contentType.startsWith( QLatin1String( "image/svg+xml" ), Qt::CaseInsensitive )
&& !contentType.startsWith( QLatin1String( "text/plain" ), Qt::CaseInsensitive ) )
{
QgsMessageLog::logMessage( tr( "Unexpected MIME type %1 received for %2" ).arg( contentType, path ), tr( "SVG" ) );
reply->deleteLater();
return mMissingSvg;
}
Expand Down

0 comments on commit d3aae3f

Please sign in to comment.