Skip to content

Commit 2e8097b

Browse files
committed
Merge pull request #2832 from m-kuhn/checkXmlKeys
Don't use invalid xml values as attribute names
2 parents 5085204 + 58751b5 commit 2e8097b

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/core/qgseditformconfig.cpp

+13-2
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,15 @@ void QgsEditFormConfig::readXml( const QDomNode& node )
242242
for ( int j = 0; j < cfgElem.attributes().size(); ++j )
243243
{
244244
QDomAttr attr = cfgElem.attributes().item( j ).toAttr();
245-
cfg[attr.name()] = attr.value();
245+
cfg.insert( attr.name(), attr.value() );
246+
}
247+
248+
QDomNodeList optionElements = cfgElem.elementsByTagName( "option" );
249+
for ( int j = 0; j < optionElements.size(); ++j )
250+
{
251+
QString key = optionElements.at( j ).toElement().attribute( "key" );
252+
QString value = optionElements.at( j ).toElement().attribute( "value" );
253+
cfg.insert( key, value );
246254
}
247255

248256
setWidgetConfig( wdgElem.attribute( "name" ), cfg );
@@ -337,7 +345,10 @@ void QgsEditFormConfig::writeXml( QDomNode& node ) const
337345

338346
while ( cfgIt != configIt.value().constEnd() )
339347
{
340-
configElem.setAttribute( cfgIt.key(), cfgIt.value().toString() );
348+
QDomElement optionElem = doc.createElement( "option" );
349+
optionElem.setAttribute( "key", cfgIt.key() );
350+
optionElem.setAttribute( "value", cfgIt.value().toString() );
351+
configElem.appendChild( optionElem );
341352
++cfgIt;
342353
}
343354

0 commit comments

Comments
 (0)