Skip to content

Commit 1def308

Browse files
committedAug 1, 2018
Be careful when restoring ui form paths from existing projects
Because these may have been corrupted and contain invalid paths, which causes a network request to be sent fetching a bad url for every vector layer (cherry-picked from 11171a3)
1 parent 349aa21 commit 1def308

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed
 

‎src/core/qgseditformconfig.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,17 @@ void QgsEditFormConfig::readXml( const QDomNode &node, QgsReadWriteContext &cont
275275
if ( !editFormNode.isNull() )
276276
{
277277
QDomElement e = editFormNode.toElement();
278+
const bool tolerantRemoteUrls = e.hasAttribute( QStringLiteral( "tolerant" ) );
278279
if ( !e.text().isEmpty() )
279-
setUiForm( context.pathResolver().readPath( e.text() ) );
280+
{
281+
const QString uiFormPath = context.pathResolver().readPath( e.text() );
282+
// <= 3.2 had a bug where invalid ui paths would get written into projects on load
283+
// to avoid restoring these invalid paths, we take a less-tolerant approach for older (untrustworthy) projects
284+
// and only set ui forms paths IF they are local files OR start with "http(s)".
285+
const bool localFile = QFileInfo::exists( uiFormPath );
286+
if ( localFile || tolerantRemoteUrls || uiFormPath.startsWith( QStringLiteral( "http" ) ) )
287+
setUiForm( uiFormPath );
288+
}
280289
}
281290

282291
QDomNode editFormInitNode = node.namedItem( QStringLiteral( "editforminit" ) );
@@ -404,6 +413,7 @@ void QgsEditFormConfig::writeXml( QDomNode &node, const QgsReadWriteContext &con
404413
QDomDocument doc( node.ownerDocument() );
405414

406415
QDomElement efField = doc.createElement( QStringLiteral( "editform" ) );
416+
efField.setAttribute( QStringLiteral( "tolerant" ), QStringLiteral( "1" ) );
407417
QDomText efText = doc.createTextNode( context.pathResolver().writePath( uiForm() ) );
408418
efField.appendChild( efText );
409419
node.appendChild( efField );

0 commit comments

Comments
 (0)
Please sign in to comment.