@@ -498,7 +498,7 @@ bool QgsCoordinateReferenceSystem::loadFromDatabase( const QString &db, const QS
498498
499499 QString mySql = " select srs_id,description,projection_acronym,"
500500 " ellipsoid_acronym,parameters,srid,auth_name||':'||auth_id,is_geo "
501- " from tbl_srs where " + expression + ' =' + quotedValue ( value ) + " order by deprecated" ;
501+ " from tbl_srs where " + expression + ' =' + QgsSqliteUtils::quotedString ( value ) + " order by deprecated" ;
502502 statement = database.prepare ( mySql, myResult );
503503 // XXX Need to free memory from the error msg if one is set
504504 if ( myResult == SQLITE_OK && statement.step () == SQLITE_ROW )
@@ -729,7 +729,7 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString &proj4String )
729729 * We try to match the proj string to and srsid using the following logic:
730730 * - perform a whole text search on proj4 string (if not null)
731731 */
732- myRecord = getRecord ( " select * from tbl_srs where parameters=" + quotedValue ( myProj4String ) + " order by deprecated" );
732+ myRecord = getRecord ( " select * from tbl_srs where parameters=" + QgsSqliteUtils::quotedString ( myProj4String ) + " order by deprecated" );
733733 if ( myRecord.empty () )
734734 {
735735 // Ticket #722 - aaronr
@@ -764,7 +764,7 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString &proj4String )
764764 myStart2 = myLat2RegExp.indexIn ( proj4String, myStart2 );
765765 proj4StringModified.replace ( myStart2 + LAT_PREFIX_LEN, myLength2 - LAT_PREFIX_LEN, lat1Str );
766766 QgsDebugMsgLevel ( " trying proj4string match with swapped lat_1,lat_2" , 4 );
767- myRecord = getRecord ( " select * from tbl_srs where parameters=" + quotedValue ( proj4StringModified.trimmed () ) + " order by deprecated" );
767+ myRecord = getRecord ( " select * from tbl_srs where parameters=" + QgsSqliteUtils::quotedString ( proj4StringModified.trimmed () ) + " order by deprecated" );
768768 }
769769 }
770770
@@ -785,7 +785,7 @@ bool QgsCoordinateReferenceSystem::createFromProj4( const QString &proj4String )
785785 QStringList myParams;
786786 Q_FOREACH ( const QString ¶m, myProj4String.split ( QRegExp ( " \\ s+(?=\\ +)" ), QString::SkipEmptyParts ) )
787787 {
788- QString arg = QStringLiteral ( " ' '||parameters||' ' LIKE %1" ).arg ( quotedValue ( QStringLiteral ( " % %1 %" ).arg ( param.trimmed () ) ) );
788+ QString arg = QStringLiteral ( " ' '||parameters||' ' LIKE %1" ).arg ( QgsSqliteUtils::quotedString ( QStringLiteral ( " % %1 %" ).arg ( param.trimmed () ) ) );
789789 if ( param.startsWith ( QLatin1String ( " +datum=" ) ) )
790790 {
791791 datum = arg;
@@ -1234,8 +1234,8 @@ long QgsCoordinateReferenceSystem::findMatchingProj()
12341234 // needed to populate the list
12351235 QString mySql = QString ( " select srs_id,parameters from tbl_srs where "
12361236 " projection_acronym=%1 and ellipsoid_acronym=%2 order by deprecated" )
1237- .arg ( quotedValue ( d->mProjectionAcronym ),
1238- quotedValue ( d->mEllipsoidAcronym ) );
1237+ .arg ( QgsSqliteUtils::quotedString ( d->mProjectionAcronym ),
1238+ QgsSqliteUtils::quotedString ( d->mEllipsoidAcronym ) );
12391239 // Get the full path name to the sqlite3 spatial reference database.
12401240 QString myDatabaseFileName = QgsApplication::srsDatabaseFilePath ();
12411241
@@ -1620,19 +1620,19 @@ long QgsCoordinateReferenceSystem::saveAsUserCrs( const QString &name )
16201620 {
16211621 mySql = " insert into tbl_srs (srs_id,description,projection_acronym,ellipsoid_acronym,parameters,is_geo) values ("
16221622 + QString::number ( USER_CRS_START_ID )
1623- + ' ,' + quotedValue ( name )
1624- + ' ,' + quotedValue ( projectionAcronym () )
1625- + ' ,' + quotedValue ( ellipsoidAcronym () )
1626- + ' ,' + quotedValue ( toProj4 () )
1623+ + ' ,' + QgsSqliteUtils::quotedString ( name )
1624+ + ' ,' + QgsSqliteUtils::quotedString ( projectionAcronym () )
1625+ + ' ,' + QgsSqliteUtils::quotedString ( ellipsoidAcronym () )
1626+ + ' ,' + QgsSqliteUtils::quotedString ( toProj4 () )
16271627 + " ,0)" ; // <-- is_geo shamelessly hard coded for now
16281628 }
16291629 else
16301630 {
16311631 mySql = " insert into tbl_srs (description,projection_acronym,ellipsoid_acronym,parameters,is_geo) values ("
1632- + quotedValue ( name )
1633- + ' ,' + quotedValue ( projectionAcronym () )
1634- + ' ,' + quotedValue ( ellipsoidAcronym () )
1635- + ' ,' + quotedValue ( toProj4 () )
1632+ + QgsSqliteUtils::quotedString ( name )
1633+ + ' ,' + QgsSqliteUtils::quotedString ( projectionAcronym () )
1634+ + ' ,' + QgsSqliteUtils::quotedString ( ellipsoidAcronym () )
1635+ + ' ,' + QgsSqliteUtils::quotedString ( toProj4 () )
16361636 + " ,0)" ; // <-- is_geo shamelessly hard coded for now
16371637 }
16381638 sqlite3_database_unique_ptr database;
@@ -1707,12 +1707,6 @@ long QgsCoordinateReferenceSystem::getRecordCount()
17071707 return myRecordCount;
17081708}
17091709
1710- QString QgsCoordinateReferenceSystem::quotedValue ( QString value )
1711- {
1712- value.replace ( ' \' ' , QLatin1String ( " ''" ) );
1713- return value.prepend ( ' \' ' ).append ( ' \' ' );
1714- }
1715-
17161710// adapted from gdal/ogr/ogr_srs_dict.cpp
17171711bool QgsCoordinateReferenceSystem::loadWkts ( QHash<int , QString> &wkts, const char *filename )
17181712{
@@ -1951,8 +1945,8 @@ int QgsCoordinateReferenceSystem::syncDatabase()
19511945 {
19521946 errMsg = nullptr ;
19531947 sql = QStringLiteral ( " UPDATE tbl_srs SET parameters=%1,description=%2,deprecated=%3 WHERE auth_name='EPSG' AND auth_id=%4" )
1954- .arg ( quotedValue ( proj4 ) )
1955- .arg ( quotedValue ( name ) )
1948+ .arg ( QgsSqliteUtils::quotedString ( proj4 ) )
1949+ .arg ( QgsSqliteUtils::quotedString ( name ) )
19561950 .arg ( deprecated ? 1 : 0 )
19571951 .arg ( it.key () );
19581952
@@ -1989,10 +1983,10 @@ int QgsCoordinateReferenceSystem::syncDatabase()
19891983 }
19901984
19911985 sql = QStringLiteral ( " INSERT INTO tbl_srs(description,projection_acronym,ellipsoid_acronym,parameters,srid,auth_name,auth_id,is_geo,deprecated) VALUES (%1,%2,%3,%4,%5,'EPSG',%5,%6,%7)" )
1992- .arg ( quotedValue ( name ),
1993- quotedValue ( projRegExp.cap ( 1 ) ),
1994- quotedValue ( ellps ),
1995- quotedValue ( proj4 ) )
1986+ .arg ( QgsSqliteUtils::quotedString ( name ),
1987+ QgsSqliteUtils::quotedString ( projRegExp.cap ( 1 ) ),
1988+ QgsSqliteUtils::quotedString ( ellps ),
1989+ QgsSqliteUtils::quotedString ( proj4 ) )
19961990 .arg ( it.key () )
19971991 .arg ( OSRIsGeographic ( crs ) )
19981992 .arg ( deprecated ? 1 : 0 );
@@ -2081,9 +2075,9 @@ int QgsCoordinateReferenceSystem::syncDatabase()
20812075 if ( proj4 != params )
20822076 {
20832077 sql = QStringLiteral ( " UPDATE tbl_srs SET parameters=%1 WHERE auth_name=%2 AND auth_id=%3" )
2084- .arg ( quotedValue ( proj4 ),
2085- quotedValue ( auth_name ),
2086- quotedValue ( auth_id ) );
2078+ .arg ( QgsSqliteUtils::quotedString ( proj4 ),
2079+ QgsSqliteUtils::quotedString ( auth_name ),
2080+ QgsSqliteUtils::quotedString ( auth_id ) );
20872081
20882082 if ( sqlite3_exec ( database.get (), sql.toUtf8 (), nullptr , nullptr , &errMsg ) == SQLITE_OK )
20892083 {
@@ -2291,7 +2285,7 @@ bool QgsCoordinateReferenceSystem::syncDatumTransform( const QString &dbPath )
22912285 int idx = map[i].idx ;
22922286 Q_ASSERT ( idx != -1 );
22932287 Q_ASSERT ( idx < n );
2294- v.insert ( i, *values[ idx ] ? quotedValue ( values[idx] ) : QStringLiteral ( " NULL" ) );
2288+ v.insert ( i, *values[ idx ] ? QgsSqliteUtils::quotedString ( values[idx] ) : QStringLiteral ( " NULL" ) );
22952289 }
22962290 CSLDestroy ( values );
22972291
0 commit comments