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 4, 2019
1 parent 089e418 commit e470b6c973e97f64bdb910cf3bb14fad45641bd2
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() )
@@ -3413,6 +3413,8 @@ class TestQgsExpression: public QObject
QTest::newRow( "multiple exp" ) << "some [% 3+ 7 %] text [% 1 + 2 %]" << "some 10 text 3";
QTest::newRow( "complex" ) << "some [%map('a', 1, 'b', 2)['a']%] text [%map('a', 1, 'b', 2)['b']%]" << "some 1 text 2";
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 e470b6c

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