diff --git a/src/gui/qgsrichtexteditor.cpp b/src/gui/qgsrichtexteditor.cpp index 172132aa0005..a2b7115d3ad0 100644 --- a/src/gui/qgsrichtexteditor.cpp +++ b/src/gui/qgsrichtexteditor.cpp @@ -757,7 +757,8 @@ void QgsRichTextEditor::setText( const QString &text ) return; } - if ( text[0] == '<' ) + const thread_local QRegularExpression sIsHtmlRx( QStringLiteral( "^\\s*<" ) ); + if ( sIsHtmlRx.match( text ).hasMatch() ) { mTextEdit->setHtml( text ); mSourceEdit->setText( text );