[vlc-commits] Qt: messages: remove HTML parsing
Francois Cartegnie
git at videolan.org
Tue Apr 16 15:28:13 CEST 2019
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Apr 16 15:10:28 2019 +0200| [b9d50bc5085321b7cfe8908841de2b16459218dc] | committer: Francois Cartegnie
Qt: messages: remove HTML parsing
and don't parse HTML from untrusted logs
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b9d50bc5085321b7cfe8908841de2b16459218dc
---
modules/gui/qt/dialogs/messages.cpp | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/modules/gui/qt/dialogs/messages.cpp b/modules/gui/qt/dialogs/messages.cpp
index 013c16f61f..88b6cfcad7 100644
--- a/modules/gui/qt/dialogs/messages.cpp
+++ b/modules/gui/qt/dialogs/messages.cpp
@@ -217,30 +217,38 @@ void MessagesDialog::sinkMessage( const MsgEvent *msg )
if( !messages->document()->isEmpty() )
messages->textCursor().insertBlock();
- QString buf = QString( "<i><font color='darkblue'>%1</font>" ).arg( msg->module );
+ /* Insert the prefix */
+ QTextCharFormat format;
+ format.setProperty( QTextFormat::FontItalic, true );
+ format.setForeground( Qt::darkBlue );
+
+ messages->textCursor().insertText( msg->module, format );
switch ( msg->priority )
{
case VLC_MSG_INFO:
- buf += "<font color='blue'> info: </font>";
+ format.setForeground( Qt::darkBlue );
+ messages->textCursor().insertText( " info: ", format );
break;
case VLC_MSG_ERR:
- buf += "<font color='red'> error: </font>";
+ format.setForeground( Qt::darkRed );
+ messages->textCursor().insertText( " error: ", format );
break;
case VLC_MSG_WARN:
- buf += "<font color='green'> warning: </font>";
+ format.setForeground( Qt::darkGreen );
+ messages->textCursor().insertText( " warning: ", format );
break;
case VLC_MSG_DBG:
default:
- buf += "<font color='grey'> debug: </font>";
+ format.setForeground( Qt::darkGray );
+ messages->textCursor().insertText( " debug: ", format );
break;
}
- /* Insert the prefix */
- messages->textCursor().insertHtml( buf /* + "</i>" */ );
-
/* Insert the message */
- messages->textCursor().insertHtml( msg->text );
+ format.setProperty( QTextFormat::FontItalic, false );
+ format.setForeground( messages->palette().foreground() );
+ messages->textCursor().insertText( msg->text, format );
/* Pass the new message thru the filter */
QTextBlock b = messages->document()->lastBlock();
More information about the vlc-commits
mailing list