From kde-commits Tue Apr 30 23:22:00 2013 From: Johannes Zarl Date: Tue, 30 Apr 2013 23:22:00 +0000 To: kde-commits Subject: [kphotoalbum] XMLDB: Don't escape strings for xml attribute values. Message-Id: <20130430232200.544BAA6071 () git ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=136736413219241 Git commit 55340bc57cb49cf2ca529f1fede80ce178bdfd90 by Johannes Zarl. Committed on 01/05/2013 at 01:20. Pushed by johanneszarl into branch 'master'. Don't escape strings for xml attribute values. BUG: 319135 M +6 -2 XMLDB/FileWriter.cpp http://commits.kde.org/kphotoalbum/55340bc57cb49cf2ca529f1fede80ce178bdfd90 diff --git a/XMLDB/FileWriter.cpp b/XMLDB/FileWriter.cpp index fb862fe..b7c0dbb 100644 --- a/XMLDB/FileWriter.cpp +++ b/XMLDB/FileWriter.cpp @@ -102,7 +102,7 @@ void XMLDB::FileWriter::saveCategories( QXmlStreamWrite= r& writer ) Q_FOREACH(const QString &name, categories) { DB::CategoryPtr category =3D DB::ImageDB::instance()->category= Collection()->categoryForName( name ); ElementWriter dummy(writer, QString::fromLatin1("Category") ); - writer.writeAttribute( QString::fromLatin1("name"), escape( na= me ) ); + writer.writeAttribute( QString::fromLatin1("name"), name ); = writer.writeAttribute( QString::fromLatin1( "icon" ), category= ->iconName() ); writer.writeAttribute( QString::fromLatin1( "show" ), QString:= :number(category->doShow()) ); @@ -269,7 +269,7 @@ void XMLDB::FileWriter::writeCategories( QXmlStreamWrit= er& writer, const DB::Ima if ( !items.isEmpty() ) { topElm.writeStartElement(); categoryElm.writeStartElement(); - writer.writeAttribute( QString::fromLatin1("name"), escape( n= ame ) ); + writer.writeAttribute( QString::fromLatin1("name"), name ); } = Q_FOREACH(const QString& itemValue, items) { @@ -320,6 +320,10 @@ bool XMLDB::FileWriter::shouldSaveCategory( const QStr= ing& categoryName ) const return shouldSave; } = +/** + * Escape problematic characters in a string that forms an XML attribute n= ame. + * N.B.: Attribute values do not need to be escaped! + */ QString XMLDB::FileWriter::escape( const QString& str ) { static QHash cache;