mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-31 00:03:42 -04:00
Escape xml characters in composer template string replacement
This commit is contained in:
parent
3c5cb06dec
commit
3a1c9efb44
@ -206,13 +206,13 @@ const QgsComposerHtml* QgsComposition::getComposerHtmlByItem( QgsComposerItem *i
|
|||||||
// an html item will be a composer frame and if it is we can try to get
|
// an html item will be a composer frame and if it is we can try to get
|
||||||
// its multiframe parent and then try to cast that to a composer html
|
// its multiframe parent and then try to cast that to a composer html
|
||||||
const QgsComposerFrame* composerFrame =
|
const QgsComposerFrame* composerFrame =
|
||||||
dynamic_cast<const QgsComposerFrame *>( item );
|
dynamic_cast<const QgsComposerFrame *>( item );
|
||||||
if ( composerFrame )
|
if ( composerFrame )
|
||||||
{
|
{
|
||||||
const QgsComposerMultiFrame * mypMultiFrame = composerFrame->multiFrame();
|
const QgsComposerMultiFrame * mypMultiFrame = composerFrame->multiFrame();
|
||||||
const QgsComposerHtml* composerHtml =
|
const QgsComposerHtml* composerHtml =
|
||||||
dynamic_cast<const QgsComposerHtml *>( mypMultiFrame );
|
dynamic_cast<const QgsComposerHtml *>( mypMultiFrame );
|
||||||
if (composerHtml)
|
if ( composerHtml )
|
||||||
{
|
{
|
||||||
return composerHtml;
|
return composerHtml;
|
||||||
}
|
}
|
||||||
@ -377,7 +377,7 @@ bool QgsComposition::loadFromTemplate( const QDomDocument& doc, QMap<QString, QS
|
|||||||
QMap<QString, QString>::const_iterator sIt = substitutionMap->constBegin();
|
QMap<QString, QString>::const_iterator sIt = substitutionMap->constBegin();
|
||||||
for ( ; sIt != substitutionMap->constEnd(); ++sIt )
|
for ( ; sIt != substitutionMap->constEnd(); ++sIt )
|
||||||
{
|
{
|
||||||
xmlString = xmlString.replace( "[" + sIt.key() + "]", sIt.value() );
|
xmlString = xmlString.replace( "[" + sIt.key() + "]", encodeStringForXML( sIt.value() ) );
|
||||||
}
|
}
|
||||||
importDoc.setContent( xmlString );
|
importDoc.setContent( xmlString );
|
||||||
}
|
}
|
||||||
@ -1570,3 +1570,14 @@ void QgsComposition::renderPage( QPainter* p, int page )
|
|||||||
|
|
||||||
mPlotStyle = savedPlotStyle;
|
mPlotStyle = savedPlotStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString QgsComposition::encodeStringForXML( const QString& str )
|
||||||
|
{
|
||||||
|
QString modifiedStr( str );
|
||||||
|
modifiedStr.replace( "&", "&" );
|
||||||
|
modifiedStr.replace( "\"", """ );
|
||||||
|
modifiedStr.replace( "'", "'" );
|
||||||
|
modifiedStr.replace( "<", "<" );
|
||||||
|
modifiedStr.replace( ">", ">" );
|
||||||
|
return modifiedStr;
|
||||||
|
}
|
||||||
|
@ -343,6 +343,8 @@ class CORE_EXPORT QgsComposition: public QGraphicsScene
|
|||||||
void removePaperItems();
|
void removePaperItems();
|
||||||
void deleteAndRemoveMultiFrames();
|
void deleteAndRemoveMultiFrames();
|
||||||
|
|
||||||
|
static QString encodeStringForXML( const QString& str );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void paperSizeChanged();
|
void paperSizeChanged();
|
||||||
void nPagesChanged();
|
void nPagesChanged();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user