Skip to content
Permalink
Browse files

[Fix #7798] (I)LIKE operator escapes regexp characters before computi…

…ng regexp
  • Loading branch information
m-kuhn committed May 13, 2013
1 parent f424e2a commit 4d3b1841ceab56c30b4d9d700382066eecdf093f
Showing with 4 additions and 3 deletions.
  1. +4 −3 src/core/qgsexpression.cpp
@@ -1936,10 +1936,11 @@ QVariant QgsExpression::NodeBinaryOperator::eval( QgsExpression* parent, QgsFeat
bool matches;
if ( mOp == boLike || mOp == boILike || mOp == boNotLike || mOp == boNotILike ) // change from LIKE syntax to regexp
{
QString esc_regexp = QRegExp::escape( regexp );
// XXX escape % and _ ???
regexp.replace( "%", ".*" );
regexp.replace( "_", "." );
matches = QRegExp( regexp, mOp == boLike || mOp == boNotLike ? Qt::CaseSensitive : Qt::CaseInsensitive ).exactMatch( str );
esc_regexp.replace( "%", ".*" );
esc_regexp.replace( "_", "." );
matches = QRegExp( esc_regexp, mOp == boLike || mOp == boNotLike ? Qt::CaseSensitive : Qt::CaseInsensitive ).exactMatch( str );
}
else
{

0 comments on commit 4d3b184

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