@@ -147,11 +147,32 @@ QgsPostgresProvider::QgsPostgresProvider(QString const & uri)
147147 {
148148 mUri .username = parm[1 ];
149149 }
150- parm = QStringList::split (" =" , conParts[4 ]);
151- if (parm.size () == 2 )
152- {
153- mUri .password = parm[1 ];
154- }
150+
151+ // The password can have '=' and ' ' characters in it, so we can't
152+ // use the split on '=' and ' ' technique - use indexOf()
153+ // instead.
154+ QString key=" password='" ;
155+ int i = connInfo.indexOf (key);
156+ if (i != -1 )
157+ {
158+ QString password = connInfo.mid (i+key.length ());
159+ // Now walk through the string till we find a ' character, but
160+ // need to allow for an escaped ' character (which will be the
161+ // \' character pair).
162+ int n = 0 ;
163+ bool escaped = false ;
164+ while (n < password.length () && (password[n] != ' \' ' || escaped))
165+ {
166+ if (password[n] == ' \\ ' )
167+ escaped = true ;
168+ else
169+ escaped = false ;
170+ n++;
171+ }
172+ // The -1 is to remove the trailing ' character
173+ mUri .password = password.left (n-1 );
174+ }
175+ else
155176 /* end uri structure */
156177
157178 QgsDebugMsg (" Geometry column is: " + geometryColumn);
@@ -266,7 +287,7 @@ QgsPostgresProvider::QgsPostgresProvider(QString const & uri)
266287 QString attnum = PQgetvalue (tresult, 0 , 0 );
267288 PQclear (tresult);
268289
269- QgsDebugMsg (" Field: " + attnum + " maps to " + QString::number (i) + " " + fieldName + " , " + \
290+ QgsDebugMsg (" Field: " + attnum + " maps to " + QString::number (i) + " " + fieldName + " , " +
270291 fieldType + " (" + QString::number (fldtyp) + " ), " + fieldSize + " , " + QString::number (fieldModifier));
271292
272293 attributeFieldsIdMap[attnum.toInt ()] = i;
@@ -1344,13 +1365,13 @@ void QgsPostgresProvider::findColumns(tableCols& cols)
13441365 temp.table_type = PQgetvalue (result, i, 6 );
13451366 temp.column_type = PQgetvalue (result, i, 7 );
13461367
1347- QgsDebugMsg (temp.view_schema + " ." \
1348- + temp.view_name + " ." \
1349- + temp.view_column_name + " <- " \
1350- + temp.table_schema + " ." \
1351- + temp.table_name + " ." \
1352- + temp.column_name + " is a '" \
1353- + temp.table_type + " ' of type " \
1368+ QgsDebugMsg (temp.view_schema + " ."
1369+ + temp.view_name + " ."
1370+ + temp.view_column_name + " <- "
1371+ + temp.table_schema + " ."
1372+ + temp.table_name + " ."
1373+ + temp.column_name + " is a '"
1374+ + temp.table_type + " ' of type "
13541375 + temp.column_type );
13551376
13561377 columnRelations[temp.view_schema + ' .' +
@@ -2471,8 +2492,8 @@ void QgsPostgresProvider::customEvent( QCustomEvent * e )
24712492
24722493 QgsDebugMsg (" QgsPostgresProvider: new extent has been saved" );
24732494
2474- QgsDebugMsg (" QgsPostgresProvider: Set extent to: " + QString::number (layerExtent.xMin ()) + " , " + \
2475- QString::number (layerExtent.yMin ()) + " " + QString::number (layerExtent.xMax ()) + " , " + \
2495+ QgsDebugMsg (" QgsPostgresProvider: Set extent to: " + QString::number (layerExtent.xMin ()) + " , " +
2496+ QString::number (layerExtent.yMin ()) + " " + QString::number (layerExtent.xMax ()) + " , " +
24762497 QString::number (layerExtent.yMax ()));
24772498
24782499 QgsDebugMsg (" QgsPostgresProvider: emitting fullExtentCalculated()" );
0 commit comments