Skip to content

Commit 7af4997

Browse files
committedApr 2, 2018
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)
1 parent 2f695b9 commit 7af4997

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed
 

‎src/core/symbology/qgssvgcache.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,10 +461,13 @@ QByteArray QgsSvgCache::getImageData( const QString &path ) const
461461
return mMissingSvg;
462462
}
463463

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

0 commit comments

Comments
 (0)
Please sign in to comment.