Skip to content

Commit f1577f1

Browse files
committedOct 7, 2014
Adding comments explaining code changes
1 parent 8b24554 commit f1577f1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed
 

‎src/providers/postgres/qgspostgresprovider.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3356,6 +3356,11 @@ QGISEXTERN bool saveStyle( const QString& uri, const QString& qmlStyle, const QS
33563356
uiFileValue = QString( ",XMLPARSE(DOCUMENT %1)" ).arg( QgsPostgresConn::quotedValue( uiFileContent ) );
33573357
}
33583358

3359+
// Note: in the construction of the INSERT and UPDATE strings the qmlStyle and sldStyle values
3360+
// can contain user entered strings, which may themselves include %## values that would be
3361+
// replaced by the QString.arg function. To ensure that the final SQL string is not corrupt these
3362+
// two values are both replaced in the final .arg call of the string construction.
3363+
33593364
QString sql = QString( "INSERT INTO layer_styles("
33603365
"f_table_catalog,f_table_schema,f_table_name,f_geometry_column,styleName,styleQML,styleSLD,useAsDefault,description,owner%11"
33613366
") VALUES ("
@@ -3371,6 +3376,7 @@ QGISEXTERN bool saveStyle( const QString& uri, const QString& qmlStyle, const QS
33713376
.arg( QgsPostgresConn::quotedValue( dsUri.username() ) )
33723377
.arg( uiFileColumn )
33733378
.arg( uiFileValue )
3379+
// Must be the final .arg replacement - see above
33743380
.arg( QgsPostgresConn::quotedValue( qmlStyle ),
33753381
QgsPostgresConn::quotedValue( sldStyle ) );
33763382

@@ -3419,6 +3425,7 @@ QGISEXTERN bool saveStyle( const QString& uri, const QString& qmlStyle, const QS
34193425
.arg( QgsPostgresConn::quotedValue( dsUri.table() ) )
34203426
.arg( QgsPostgresConn::quotedValue( dsUri.geometryColumn() ) )
34213427
.arg( QgsPostgresConn::quotedValue( styleName.isEmpty() ? dsUri.table() : styleName ) )
3428+
// Must be the final .arg replacement - see above
34223429
.arg( QgsPostgresConn::quotedValue( qmlStyle ),
34233430
QgsPostgresConn::quotedValue( sldStyle ) );
34243431
}

0 commit comments

Comments
 (0)
Please sign in to comment.