Skip to content
Permalink
Browse files

Fix newline characters break embedded expressions

Fixes #21471

(cherry picked from commit daeb3d8)
  • Loading branch information
nyalldawson committed Mar 7, 2019
1 parent 53c9096 commit d036a5f5af21da051b8367f60f749a10838fb508
Showing with 3 additions and 1 deletion.
  1. +1 −1 src/core/expression/qgsexpression.cpp
  2. +2 −0 tests/src/core/testqgsexpression.cpp
@@ -474,7 +474,7 @@ QString QgsExpression::replaceExpressionText( const QString &action, const QgsEx
int index = 0;
while ( index < action.size() )
{
static const QRegularExpression sRegEx{ QStringLiteral( "\\[%(.*?)%\\]" ) };
static const QRegularExpression sRegEx{ QStringLiteral( "\\[%(.*?)%\\]" ), QRegularExpression::MultilineOption | QRegularExpression::DotMatchesEverythingOption };

const QRegularExpressionMatch match = sRegEx.match( action, index );
if ( !match.hasMatch() )
@@ -3212,6 +3212,8 @@ class TestQgsExpression: public QObject
QTest::newRow( "simple exp" ) << "some text [% 1 + 2 %]" << "some text 3";
QTest::newRow( "multiple exp" ) << "some [% 3+ 7 %] text [% 1 + 2 %]" << "some 10 text 3";
QTest::newRow( "complex2" ) << "some [% 'my text]' %] text" << "some my text] text";
QTest::newRow( "newline 1" ) << "some \n [% 1 + 2 %] \n text" << "some \n 3 \n text";
QTest::newRow( "newline 2" ) << "some [% \n 1 \n + \n 2 %] \n text" << "some 3 \n text";
}

void testReplaceExpressionText()

0 comments on commit d036a5f

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