diff --git a/src/infoplugins/linux/fdonotify/FdoNotifyPlugin.cpp b/src/infoplugins/linux/fdonotify/FdoNotifyPlugin.cpp index acbf21092..c07694560 100644 --- a/src/infoplugins/linux/fdonotify/FdoNotifyPlugin.cpp +++ b/src/infoplugins/linux/fdonotify/FdoNotifyPlugin.cpp @@ -48,6 +48,8 @@ #include #include +// QTextDocument provides Qt::escape() +#include namespace Tomahawk { @@ -174,17 +176,28 @@ FdoNotifyPlugin::nowPlaying( const QVariant &input ) if ( !hash.contains( "title" ) || !hash.contains( "artist" ) || !hash.contains( "album" ) ) return; + QString messageText; // If the window manager supports notification styling then use it. - const char* messageTemplate = "\"%1\" by %2%3."; - const char* albumMessageTemplate = "on \"%1\""; if ( m_wmSupportsBodyMarkup ) { - messageTemplate = "%1
by %2%3."; - albumMessageTemplate = "
on %1"; + // Remark: If using xml-based markup in notifications, the supplied strings need to be escaped. + QString album; + if ( !hash[ "album" ].isEmpty() ) + album = tr( "
on %1" ).arg( Qt::escape( hash[ "album" ] ) ); + messageText = tr( "%1
by %2%3." ) + .arg( Qt::escape( hash[ "title" ] ) ) + .arg( Qt::escape( hash[ "artist" ] ) ) + .arg( album ); } - QString messageText = tr( messageTemplate ) + else + { + QString album; + if ( !hash[ "album" ].isEmpty() ) + album = QString( " %1" ).arg( tr( "on \"%1\"" ).arg( hash[ "album" ] ) ); + messageText = tr( "\"%1\" by %2%3." ) .arg( hash[ "title" ] ) .arg( hash[ "artist" ] ) - .arg( hash[ "album" ].isEmpty() ? QString() : QString( " %1" ).arg( tr( albumMessageTemplate ).arg( hash[ "album" ] ) ) ); + .arg( album ); + } tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "sending message" << messageText;