Skip to content
Permalink
Browse files

Allow remote SVG files with text/plain MIME type, instead of only

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.

(cherry-picked from d3aae3f)
  • Loading branch information
nyalldawson committed Apr 2, 2018
1 parent 2f695b9 commit 7af4997c90433a6d84ea921dde71de77bb2c1b10
Showing with 5 additions and 2 deletions.
  1. +5 −2 src/core/symbology/qgssvgcache.cpp
@@ -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;
}

0 comments on commit 7af4997

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