Skip to content

Commit

Permalink
[Fix #7798] (I)LIKE operator escapes regexp characters before computi…
Browse files Browse the repository at this point in the history
…ng regexp
  • Loading branch information
m-kuhn committed May 13, 2013
1 parent f424e2a commit 4d3b184
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/core/qgsexpression.cpp
Expand Up @@ -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
{
Expand Down

0 comments on commit 4d3b184

Please sign in to comment.