[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/lib/store
From: David Faure <faure () kde ! org>
Date: 2004-06-14 21:16:16
Message-ID: 20040614211616.B6A739145 () office ! kde ! org
[Download RAW message or body]
CVS commit by faure:
Rob was right, there was a bug with very long attributes.
M +11 -8 koxmlwriter.cc 1.13
M +1 -1 koxmlwriter.h 1.14
--- koffice/lib/store/koxmlwriter.cc #1.12:1.13
@@ -185,5 +185,5 @@ void KoXmlWriter::addTextNode( const cha
}
- char* escaped = escapeForXML( cstr );
+ char* escaped = escapeForXML( cstr, -1 );
writeCString( escaped );
if(escaped != m_escapeBuffer)
@@ -196,5 +196,5 @@ void KoXmlWriter::addAttribute( const ch
writeCString( attrName );
writeCString("=\"");
- char* escaped = escapeForXML( value );
+ char* escaped = escapeForXML( value, -1 );
writeCString( escaped );
if(escaped != m_escapeBuffer)
@@ -234,5 +234,5 @@ void KoXmlWriter::writeString( const QSt
// In case of a reallocation (ret value != m_buffer), the caller owns the return value,
// it must delete it (with [])
-char* KoXmlWriter::escapeForXML( const char* source ) const
+char* KoXmlWriter::escapeForXML( const char* source, int length = -1 ) const
{
// we're going to be pessimistic on char length; so lets make the outputLength less
@@ -241,4 +241,5 @@ char* KoXmlWriter::escapeForXML( const c
char* destination = m_escapeBuffer;
char* output = m_escapeBuffer;
+ const char* src = source; // src moves, source remains
for ( ;; ) {
if(destination >= destBoundary) {
@@ -246,6 +247,8 @@ char* KoXmlWriter::escapeForXML( const c
// be bigger than the escape buffer (this shouldn't happen very often...),
// we drop the idea of using it, and we allocate a bigger buffer.
- uint len = qstrlen( source ); // expensive...
- uint newLength = len * 6 + 1; // worst case. 6 is due to " and '
+ // Note that this if() can only be hit once per call to the method.
+ if ( length == -1 )
+ length = qstrlen( source ); // expensive...
+ uint newLength = length * 6 + 1; // worst case. 6 is due to " and '
char* buffer = new char[ newLength ];
destBoundary = buffer + newLength;
@@ -255,5 +258,5 @@ char* KoXmlWriter::escapeForXML( const c
destination = buffer + amountOfCharsAlreadyCopied;
}
- switch( *source ) {
+ switch( *src ) {
case 60: // <
memcpy( destination, "<", 4 );
@@ -282,8 +285,8 @@ char* KoXmlWriter::escapeForXML( const c
return output;
default:
- *destination++ = *source++;
+ *destination++ = *src++;
continue;
}
- ++source;
+ ++src;
}
// NOTREACHED (see case 0)
--- koffice/lib/store/koxmlwriter.h #1.13:1.14
@@ -212,5 +212,5 @@ private:
}
}
- char* escapeForXML( const char* source ) const;
+ char* escapeForXML( const char* source, int length ) const;
bool prepareForChild();
void init();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic