summaryrefslogtreecommitdiff
path: root/libopie
Unidiff
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/xmltree.cc42
-rw-r--r--libopie/xmltree.h2
2 files changed, 19 insertions, 25 deletions
diff --git a/libopie/xmltree.cc b/libopie/xmltree.cc
index d5ce74a..3d03cc6 100644
--- a/libopie/xmltree.cc
+++ b/libopie/xmltree.cc
@@ -19,3 +19,3 @@
19 19
20 20#include <qpe/stringutil.h>
21#include <opie/xmltree.h> 21#include <opie/xmltree.h>
@@ -26,23 +26,2 @@
26 26
27namespace
28{
29
30/**
31 Encode an attribute value upon saving.
32 replaces '"' with "&quot"
33 replaces '<' with "&lt"
34 replaces '&' with "&amp"
35 replaces '>' with "&gt"
36*/
37QString encodeAttr( const QString& str )
38{
39 QString encAttr( str ); // cause of the const parameter
40 encAttr = encAttr.replace( QRegExp( "[<]" ), "&lt" );
41 encAttr = encAttr.replace( QRegExp( "[>]" ), "&gt" );
42 encAttr = encAttr.replace( QRegExp( "[\"]" ), "&quot" );
43 encAttr = encAttr.replace( QRegExp( "[&]" ), "&amp" );
44 return encAttr;
45}
46
47}
48 27
@@ -112,3 +91,14 @@ void XMLElement::insertAfter( XMLElement *newChild, XMLElement *refChild )
112} 91}
113 92QString XMLElement::attribute(const QString &attr )const
93{
94 if ( !m_attributes.contains( attr ) )
95 return QString::null;
96 AttributeMap::ConstIterator it = m_attributes.find( attr );
97 return it.data();
98}
99void XMLElement::setAttribute(const QString &attr, const QString &value )
100{
101 m_attributes.remove( attr );
102 m_attributes.insert( attr, value );
103}
114void XMLElement::insertBefore( XMLElement *newChild, XMLElement *refChild ) 104void XMLElement::insertBefore( XMLElement *newChild, XMLElement *refChild )
@@ -165,3 +155,3 @@ void XMLElement::save( QTextStream &s, uint indent )
165 { 155 {
166 s << encodeAttr( m_value ); 156 s << Qtopia::escapeString( m_value );
167 return; 157 return;
@@ -181,3 +171,3 @@ void XMLElement::save( QTextStream &s, uint indent )
181 { 171 {
182 s << it.key() << "=\"" << encodeAttr( it.data() ) << "\""; 172 s << it.key() << "=\"" << Qtopia::escapeString( it.data() ) << "\"";
183 s << " "; 173 s << " ";
@@ -326 +316,3 @@ XMLElement *XMLElement::load( const QString &fileName )
326} 316}
317
318
diff --git a/libopie/xmltree.h b/libopie/xmltree.h
index 7f1b7b7..7f50365 100644
--- a/libopie/xmltree.h
+++ b/libopie/xmltree.h
@@ -86,2 +86,4 @@ public:
86 86
87 QString attribute(const QString &)const;
88 void setAttribute( const QString &attr, const QString &value );
87 void save( QTextStream &stream, uint indent = 0 ); 89 void save( QTextStream &stream, uint indent = 0 );