Author: arielch Date: Sun Mar 24 13:21:32 2013 New Revision: 1460356 URL: http://svn.apache.org/r1460356 Log: i121926 - fix malformed PROPFIND/PROPPATCH request body
Modified: openoffice/trunk/main/ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx openoffice/trunk/main/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx Modified: openoffice/trunk/main/ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx?rev=1460356&r1=1460355&r2=1460356&view=diff ============================================================================== --- openoffice/trunk/main/ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx (original) +++ openoffice/trunk/main/ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx Sun Mar 24 13:21:32 2013 @@ -28,6 +28,8 @@ #include "webdavresponseparser.hxx" #include <comphelper/seqstream.hxx> +#include <rtl/ustrbuf.hxx> + using namespace com::sun::star; @@ -94,14 +96,20 @@ serf_bucket_t * SerfPropFindReqProcImpl: // body bucket - certain properties OR all properties OR only property names serf_bucket_t* body_bkt = 0; - rtl::OUString aBodyText; + rtl::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 ++ ) { @@ -110,34 +118,32 @@ serf_bucket_t * SerfPropFindReqProcImpl: thePropName ); /* <*propname* xmlns="*propns*" /> */ - aBodyText += rtl::OUString::createFromAscii( "<" ); - aBodyText += rtl::OUString::createFromAscii( thePropName.name ); - aBodyText += rtl::OUString::createFromAscii( " xmlnx=\"" ); - aBodyText += rtl::OUString::createFromAscii( thePropName.nspace ); - aBodyText += rtl::OUString::createFromAscii( "\"/>" ); + aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "<" )); + aBuffer.appendAscii( thePropName.name ); + aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( " xmlnx=\"" )); + aBuffer.appendAscii( thePropName.nspace ); + aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "\"/>" )); } - aBodyText = rtl::OUString::createFromAscii( "<prop>" ) + - aBodyText + - rtl::OUString::createFromAscii( "</prop>" ); + aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "</prop>" )); } else { if ( mbOnlyPropertyNames ) { - aBodyText = rtl::OUString::createFromAscii( "<propname/>" ); + aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "<propname/>" )); } else { - aBodyText = rtl::OUString::createFromAscii( "<allprop/>" ); + aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "<allprop/>" )); } } - aBodyText = rtl::OUString::createFromAscii( PROPFIND_HEADER ) + - aBodyText + - rtl::OUString::createFromAscii( PROPFIND_TRAILER ); - body_bkt = SERF_BUCKET_SIMPLE_STRING( rtl::OUStringToOString( aBodyText, RTL_TEXTENCODING_UTF8 ), - 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 Modified: openoffice/trunk/main/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx?rev=1460356&r1=1460355&r2=1460356&view=diff ============================================================================== --- openoffice/trunk/main/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx (original) +++ openoffice/trunk/main/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx Sun Mar 24 13:21:32 2013 @@ -23,6 +23,7 @@ #include "precompiled_ucb.hxx" #include <rtl/ustring.hxx> +#include <rtl/ustrbuf.hxx> #include "DAVProperties.hxx" #include "UCBDeadPropertyValue.hxx" @@ -53,20 +54,33 @@ serf_bucket_t * SerfPropPatchReqProcImpl // body bucket serf_bucket_t* body_bkt = 0; - rtl::OUString aBodyText; + rtl::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 += rtl::OUString::createFromAscii( "<" ); - aBodyText += rtl::OUString::createFromAscii( OpCodes[lastOp] ); - aBodyText += rtl::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 ) @@ -79,24 +93,24 @@ serf_bucket_t * SerfPropPatchReqProcImpl if ( rProperty.operation != lastOp ) { // </prop></*last operation code*><*operation code><prop> - aBodyText += rtl::OUString::createFromAscii( "</prop></" ); - aBodyText += rtl::OUString::createFromAscii( OpCodes[lastOp] ); - aBodyText += rtl::OUString::createFromAscii( "><" ); - aBodyText += rtl::OUString::createFromAscii( OpCodes[rProperty.operation] ); - aBodyText += rtl::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 += rtl::OUString::createFromAscii( "<" ); - aBodyText += rtl::OUString::createFromAscii( thePropName.name ); - aBodyText += rtl::OUString::createFromAscii( " xmlns=\"" ); - aBodyText += rtl::OUString::createFromAscii( thePropName.nspace ); - aBodyText += rtl::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 += rtl::OUString::createFromAscii( ">" ); + aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( ">" )); rtl::OUString aStringValue; if ( DAVProperties::isUCBDeadProperty( thePropName ) ) @@ -108,33 +122,32 @@ serf_bucket_t * SerfPropPatchReqProcImpl { rProperty.value >>= aStringValue; } - aBodyText += aStringValue; - aBodyText += rtl::OUString::createFromAscii( "</" ); - aBodyText += rtl::OUString::createFromAscii( thePropName.name ); - aBodyText += rtl::OUString::createFromAscii( ">" ); + aBuffer.append( aStringValue ); + aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "</" )); + aBuffer.appendAscii( thePropName.name ); + aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( ">" )); } else { // /> - aBodyText += rtl::OUString::createFromAscii( "/>" ); + aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/>" )); } lastOp = rProperty.operation; } // </prop></*last operation code*> - aBodyText += rtl::OUString::createFromAscii( "</prop></" ); - aBodyText += rtl::OUString::createFromAscii( OpCodes[lastOp] ); - aBodyText += rtl::OUString::createFromAscii( ">" ); - - // add PropPatch xml header in front - aBodyText = rtl::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 += rtl::OUString::createFromAscii( PROPPATCH_TRAILER ); + aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( PROPPATCH_TRAILER )); - body_bkt = SERF_BUCKET_SIMPLE_STRING( rtl::OUStringToOString( aBodyText, RTL_TEXTENCODING_UTF8 ), - pSerfBucketAlloc ); + aBodyText = rtl::OUStringToOString( aBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ); + body_bkt = serf_bucket_simple_copy_create( aBodyText.getStr(), + aBodyText.getLength(), + pSerfBucketAlloc ); } }