Skip to content

Commit

Permalink
Be careful when restoring ui form paths from existing projects
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
nyalldawson committed Aug 1, 2018
1 parent 349aa21 commit 1def308
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/core/qgseditformconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,17 @@ void QgsEditFormConfig::readXml( const QDomNode &node, QgsReadWriteContext &cont
if ( !editFormNode.isNull() )
{
QDomElement e = editFormNode.toElement();
const bool tolerantRemoteUrls = e.hasAttribute( QStringLiteral( "tolerant" ) );
if ( !e.text().isEmpty() )
setUiForm( context.pathResolver().readPath( e.text() ) );
{
const QString uiFormPath = context.pathResolver().readPath( e.text() );
// <= 3.2 had a bug where invalid ui paths would get written into projects on load
// to avoid restoring these invalid paths, we take a less-tolerant approach for older (untrustworthy) projects
// and only set ui forms paths IF they are local files OR start with "http(s)".
const bool localFile = QFileInfo::exists( uiFormPath );
if ( localFile || tolerantRemoteUrls || uiFormPath.startsWith( QStringLiteral( "http" ) ) )
setUiForm( uiFormPath );
}
}

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

QDomElement efField = doc.createElement( QStringLiteral( "editform" ) );
efField.setAttribute( QStringLiteral( "tolerant" ), QStringLiteral( "1" ) );
QDomText efText = doc.createTextNode( context.pathResolver().writePath( uiForm() ) );
efField.appendChild( efText );
node.appendChild( efField );
Expand Down

0 comments on commit 1def308

Please sign in to comment.