Skip to content

Commit

Permalink
Fix newline characters break embedded expressions
Browse files Browse the repository at this point in the history
Fixes #21471

(cherry picked from commit daeb3d8)
  • Loading branch information
nyalldawson committed Mar 5, 2019
1 parent 089e418 commit e470b6c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/expression/qgsexpression.cpp
Expand Up @@ -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() )
Expand Down
2 changes: 2 additions & 0 deletions tests/src/core/testqgsexpression.cpp
Expand Up @@ -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()
Expand Down

0 comments on commit e470b6c

Please sign in to comment.