Skip to content

Commit 4d3b184

Browse files
committedMay 13, 2013
[Fix #7798] (I)LIKE operator escapes regexp characters before computing regexp
1 parent f424e2a commit 4d3b184

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed
 

‎src/core/qgsexpression.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -1936,10 +1936,11 @@ QVariant QgsExpression::NodeBinaryOperator::eval( QgsExpression* parent, QgsFeat
19361936
bool matches;
19371937
if ( mOp == boLike || mOp == boILike || mOp == boNotLike || mOp == boNotILike ) // change from LIKE syntax to regexp
19381938
{
1939+
QString esc_regexp = QRegExp::escape( regexp );
19391940
// XXX escape % and _ ???
1940-
regexp.replace( "%", ".*" );
1941-
regexp.replace( "_", "." );
1942-
matches = QRegExp( regexp, mOp == boLike || mOp == boNotLike ? Qt::CaseSensitive : Qt::CaseInsensitive ).exactMatch( str );
1941+
esc_regexp.replace( "%", ".*" );
1942+
esc_regexp.replace( "_", "." );
1943+
matches = QRegExp( esc_regexp, mOp == boLike || mOp == boNotLike ? Qt::CaseSensitive : Qt::CaseInsensitive ).exactMatch( str );
19431944
}
19441945
else
19451946
{

0 commit comments

Comments
 (0)
Please sign in to comment.