Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix insufficiently escaped backslash in regular expressions
Genealizes the fix of #52293 to
other places exhibiting the same issue.
  • Loading branch information
rouault authored and nyalldawson committed Apr 1, 2023
1 parent 88a812c commit b5fd447
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/core/expression/qgsexpressionnodeimpl.cpp
Expand Up @@ -1491,7 +1491,7 @@ bool QgsExpressionNodeColumnRef::prepareNode( QgsExpression *parent, const QgsEx

QString QgsExpressionNodeColumnRef::dump() const
{
const thread_local QRegularExpression re( QStringLiteral( "^[A-Za-z_\x80-\xff][A-Za-z0-9_\x80-\xff]*$" ) );
const thread_local QRegularExpression re( QStringLiteral( "^[A-Za-z_\\x80-\\xff][A-Za-z0-9_\\x80-\\xff]*$" ) );
const QRegularExpressionMatch match = re.match( mName );
return match.hasMatch() ? mName : QgsExpression::quotedColumnRef( mName );
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgssqlstatement.cpp
Expand Up @@ -92,7 +92,7 @@ QString QgsSQLStatement::quotedIdentifierIfNeeded( const QString &name )
return quotedIdentifier( name );
}
}
const thread_local QRegularExpression IDENTIFIER_RE( "^[A-Za-z_\x80-\xff][A-Za-z0-9_\x80-\xff]*$" );
const thread_local QRegularExpression IDENTIFIER_RE( "^[A-Za-z_\\x80-\\xff][A-Za-z0-9_\\x80-\\xff]*$" );
return IDENTIFIER_RE.match( name ).hasMatch() ? name : quotedIdentifier( name );
}

Expand Down
2 changes: 1 addition & 1 deletion src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -791,7 +791,7 @@ QString QgsPostgresUtils::andWhereClauses( const QString &c1, const QString &c2

void QgsPostgresUtils::replaceInvalidXmlChars( QString &xml )
{
static const QRegularExpression replaceRe { QStringLiteral( "([\x00-\x08\x0B-\x1F\x7F])" ) };
static const QRegularExpression replaceRe { QStringLiteral( "([\\x00-\\x08\\x0B-\\x1F\\x7F])" ) };
QRegularExpressionMatchIterator it {replaceRe.globalMatch( xml ) };
while ( it.hasNext() )
{
Expand Down
2 changes: 1 addition & 1 deletion src/providers/virtual/qgsvirtuallayerqueryparser.cpp
Expand Up @@ -80,7 +80,7 @@ namespace QgsVirtualLayerQueryParser

// look for special comments in SQL
// a column name followed by /*:type*/
const thread_local QRegularExpression rx( "([a-zA-Z_\x80-\xFF][a-zA-Z0-9_\x80-\xFF]*)\\s*/\\*:(int|real|text|((?:multi)?(?:point|linestring|polygon)):(\\d+))\\s*\\*/", QRegularExpression::CaseInsensitiveOption );
const thread_local QRegularExpression rx( "([a-zA-Z_\\x80-\\xFF][a-zA-Z0-9_\\x80-\\xFF]*)\\s*/\\*:(int|real|text|((?:multi)?(?:point|linestring|polygon)):(\\d+))\\s*\\*/", QRegularExpression::CaseInsensitiveOption );
int pos = 0;

QRegularExpressionMatch match = rx.match( query, pos );
Expand Down

0 comments on commit b5fd447

Please sign in to comment.