summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorAriel Constenla-Haile <arielch@apache.org>2013-03-24 12:21:32 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-05-27 20:25:38 +0100
commit7056e8ef89e938e38fc5b2b8a7493f0c79d5efd4 (patch)
treeeccbebe77941201ef856be90d3c22e7668824ae6 /ucb
parent3c18e25efdbbc13be3a0c6ed354d5e7a46feb451 (diff)
Resolves@ #i121926# fix malformed PROPFIND/PROPPATCH request body
(cherry picked from commit 3c83ceae5e4ff5afe20ea76aeaaae6303cdaec2d) Conflicts: ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx Change-Id: I13dab5fb80235e2ab968a1492c05bf579ba08d40
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx28
-rw-r--r--ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx77
2 files changed, 59 insertions, 46 deletions
diff --git a/ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx b/ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx
index ef02e68fcc27..ccceaf486d5b 100644
--- a/ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx
+++ b/ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx
@@ -23,6 +23,8 @@
#include "webdavresponseparser.hxx"
#include <comphelper/seqstream.hxx>
+#include <rtl/ustrbuf.hxx>
+
using namespace com::sun::star;
@@ -89,14 +91,20 @@ serf_bucket_t * SerfPropFindReqProcImpl::createSerfRequestBucket( serf_request_t
// body bucket - certain properties OR all properties OR only property names
serf_bucket_t* body_bkt = 0;
- OUString aBodyText;
+ OString aBodyText;
{
+ // TODO is it really needed a Unicode string buffer?
+ // All properties and property names aren't supposed to be ASCII?
+ rtl::OUStringBuffer aBuffer;
+ aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( PROPFIND_HEADER ));
+
// create and fill body bucket with requested properties
const int nPropCount = ( !mbOnlyPropertyNames && mpPropNames )
? mpPropNames->size()
: 0;
if ( nPropCount > 0 )
{
+ aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "<prop>" ) );
SerfPropName thePropName;
for ( int theIndex = 0; theIndex < nPropCount; theIndex ++ )
{
@@ -120,23 +128,19 @@ serf_bucket_t * SerfPropFindReqProcImpl::createSerfRequestBucket( serf_request_t
{
if ( mbOnlyPropertyNames )
{
- aBodyText = OUString::createFromAscii( "<propname/>" );
+ aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "<propname/>" ));
}
else
{
- aBodyText = OUString::createFromAscii( "<allprop/>" );
+ aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "<allprop/>" ));
}
}
- aBodyText = OUString::createFromAscii( PROPFIND_HEADER ) +
- aBodyText +
- OUString::createFromAscii( PROPFIND_TRAILER );
- body_bkt = SERF_BUCKET_SIMPLE_STRING( OUStringToOString( aBodyText, RTL_TEXTENCODING_UTF8 ),
- pSerfBucketAlloc );
- if ( useChunkedEncoding() )
- {
- body_bkt = serf_bucket_chunk_create( body_bkt, pSerfBucketAlloc );
- }
+ aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( PROPFIND_TRAILER ));
+ aBodyText = rtl::OUStringToOString( aBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8 );
+ body_bkt = serf_bucket_simple_copy_create( aBodyText.getStr(),
+ aBodyText.getLength(),
+ pSerfBucketAlloc );
}
// create serf request
diff --git a/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx b/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx
index d504a6658a3d..c3e95b4a60d9 100644
--- a/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx
+++ b/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx
@@ -18,6 +18,7 @@
*/
#include <rtl/ustring.hxx>
+#include <rtl/ustrbuf.hxx>
#include "DAVProperties.hxx"
#include "UCBDeadPropertyValue.hxx"
@@ -48,20 +49,33 @@ serf_bucket_t * SerfPropPatchReqProcImpl::createSerfRequestBucket( serf_request_
// body bucket
serf_bucket_t* body_bkt = 0;
- OUString aBodyText;
+ OString aBodyText;
{
// create and fill body bucket with properties to be set or removed
- static const char* OpCodes[2] = { "set", "remove" };
+ static const struct
+ {
+ const char *str;
+ sal_Int32 len;
+ }
+ OpCode [] = {
+ { RTL_CONSTASCII_STRINGPARAM( "set" ) },
+ { RTL_CONSTASCII_STRINGPARAM( "remove" ) }
+ };
const int nPropCount = ( mpProperties != 0 )
? mpProperties->size()
: 0;
if ( nPropCount > 0 )
{
+ rtl::OUStringBuffer aBuffer;
+ // add PropPatch xml header in front
+ aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( PROPPATCH_HEADER ));
+
// <*operation code*><prop>
+
ProppatchOperation lastOp = (*mpProperties)[ 0 ].operation;
- aBodyText += OUString::createFromAscii( "<" );
- aBodyText += OUString::createFromAscii( OpCodes[lastOp] );
- aBodyText += OUString::createFromAscii( "><prop>" );
+ aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "<" ));
+ aBuffer.appendAscii( OpCode[lastOp].str, OpCode[lastOp].len );
+ aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "><prop>" ));
SerfPropName thePropName;
for ( int n = 0; n < nPropCount; ++n )
@@ -74,24 +88,24 @@ serf_bucket_t * SerfPropPatchReqProcImpl::createSerfRequestBucket( serf_request_
if ( rProperty.operation != lastOp )
{
// </prop></*last operation code*><*operation code><prop>
- aBodyText += OUString::createFromAscii( "</prop></" );
- aBodyText += OUString::createFromAscii( OpCodes[lastOp] );
- aBodyText += OUString::createFromAscii( "><" );
- aBodyText += OUString::createFromAscii( OpCodes[rProperty.operation] );
- aBodyText += OUString::createFromAscii( "><prop>" );
+ aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "</prop></" ));
+ aBuffer.appendAscii( OpCode[lastOp].str, OpCode[lastOp].len );
+ aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "><" ));
+ aBuffer.appendAscii( OpCode[rProperty.operation].str, OpCode[rProperty.operation].len );
+ aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "><prop>" ));
}
// <*propname* xmlns="*propns*"
- aBodyText += OUString::createFromAscii( "<" );
- aBodyText += OUString::createFromAscii( thePropName.name );
- aBodyText += OUString::createFromAscii( " xmlns=\"" );
- aBodyText += OUString::createFromAscii( thePropName.nspace );
- aBodyText += OUString::createFromAscii( "\"" );
+ aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "<" ));
+ aBuffer.appendAscii( thePropName.name );
+ aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( " xmlns=\"" ));
+ aBuffer.appendAscii( thePropName.nspace );
+ aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "\"" ));
if ( rProperty.operation == PROPSET )
{
// >*property value*</*propname*>
- aBodyText += OUString::createFromAscii( ">" );
+ aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( ">" ));
OUString aStringValue;
if ( DAVProperties::isUCBDeadProperty( thePropName ) )
@@ -103,37 +117,32 @@ serf_bucket_t * SerfPropPatchReqProcImpl::createSerfRequestBucket( serf_request_
{
rProperty.value >>= aStringValue;
}
- aBodyText += aStringValue;
- aBodyText += OUString::createFromAscii( "</" );
- aBodyText += OUString::createFromAscii( thePropName.name );
- aBodyText += OUString::createFromAscii( ">" );
+ aBuffer.append( aStringValue );
+ aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "</" ));
+ aBuffer.appendAscii( thePropName.name );
+ aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( ">" ));
}
else
{
// />
- aBodyText += OUString::createFromAscii( "/>" );
+ aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/>" ));
}
lastOp = rProperty.operation;
}
// </prop></*last operation code*>
- aBodyText += OUString::createFromAscii( "</prop></" );
- aBodyText += OUString::createFromAscii( OpCodes[lastOp] );
- aBodyText += OUString::createFromAscii( ">" );
-
- // add PropPatch xml header in front
- aBodyText = OUString::createFromAscii( PROPPATCH_HEADER ) + aBodyText;
+ aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "</prop></" ));
+ aBuffer.appendAscii( OpCode[lastOp].str, OpCode[lastOp].len );
+ aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( ">" ));
// add PropPatch xml trailer at end
- aBodyText += OUString::createFromAscii( PROPPATCH_TRAILER );
+ aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( PROPPATCH_TRAILER ));
- body_bkt = SERF_BUCKET_SIMPLE_STRING( OUStringToOString( aBodyText, RTL_TEXTENCODING_UTF8 ),
- pSerfBucketAlloc );
- if ( useChunkedEncoding() )
- {
- body_bkt = serf_bucket_chunk_create( body_bkt, pSerfBucketAlloc );
- }
+ aBodyText = rtl::OUStringToOString( aBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8 );
+ body_bkt = serf_bucket_simple_copy_create( aBodyText.getStr(),
+ aBodyText.getLength(),
+ pSerfBucketAlloc );
}
}