diff options
author | Mikhail Voytenko <mav@openoffice.org> | 2010-03-22 08:53:48 +0100 |
---|---|---|
committer | Mikhail Voytenko <mav@openoffice.org> | 2010-03-22 08:53:48 +0100 |
commit | daebd00fedd0b1cdb7b6f17d007581733f493d7f (patch) | |
tree | e220be2d5574026a9edc46ed0ab16d2a2413f3bc /svtools/source | |
parent | dadd371743f7f904e1f6bf020603b65e0a43e13b (diff) |
sw321bf01: #i106861# encode the display name
Diffstat (limited to 'svtools/source')
-rw-r--r-- | svtools/source/misc/transfer.cxx | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/svtools/source/misc/transfer.cxx b/svtools/source/misc/transfer.cxx index 4628c0d4b846..7b30e06220e6 100644 --- a/svtools/source/misc/transfer.cxx +++ b/svtools/source/misc/transfer.cxx @@ -42,6 +42,7 @@ #include <vos/mutex.hxx> #include <rtl/memory.h> #include <rtl/uuid.h> +#include <rtl/uri.hxx> #ifndef DEBUG_HXX #include <tools/debug.hxx> #endif @@ -154,6 +155,10 @@ SvStream& operator<<( SvStream& rOStm, const TransferableObjectDescriptor& rObjD } // ----------------------------------------------------------------------------- +// the reading of the parameter is done using the special service ::com::sun::star::datatransfer::MimeContentType, +// a similar approach should be implemented for creation of the mimetype string; +// for now the set of acceptable characters has to be hardcoded, in future it should be part of the service that creates the mimetype +const ::rtl::OUString aQuotedParamChars = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "()<>@,;:\\\"/[]?=!#$%&'*+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ^_`abcdefghijklmnopqrstuvwxyz{|}~. " ) ); static ::rtl::OUString ImplGetParameterString( const TransferableObjectDescriptor& rObjDesc ) { @@ -177,8 +182,21 @@ static ::rtl::OUString ImplGetParameterString( const TransferableObjectDescripto if( rObjDesc.maDisplayName.Len() ) { + // the display name might contain unacceptable characters, encode all of them + // this seems to be the only parameter currently that might contain such characters + sal_Bool pToAccept[128]; + for ( sal_Int32 nBInd = 0; nBInd < 128; nBInd++ ) + pToAccept[nBInd] = sal_False; + + for ( sal_Int32 nInd = 0; nInd < aQuotedParamChars.getLength(); nInd++ ) + { + sal_Unicode nChar = aQuotedParamChars.getStr()[nInd]; + if ( nChar >= 0 && nChar < 128 ) + pToAccept[nChar] = sal_True; + } + aParams += ::rtl::OUString::createFromAscii( ";displayname=\"" ); - aParams += rObjDesc.maDisplayName; + aParams += ::rtl::Uri::encode( rObjDesc.maDisplayName, pToAccept, rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8 ); aParams += aChar; } @@ -248,7 +266,9 @@ static void ImplSetParameterString( TransferableObjectDescriptor& rObjDesc, cons if( xMimeType->hasParameter( aDisplayNameString ) ) { - rObjDesc.maDisplayName = xMimeType->getParameterValue( aDisplayNameString ); + // the display name might contain unacceptable characters, in this case they should be encoded + // this seems to be the only parameter currently that might contain such characters + rObjDesc.maDisplayName = ::rtl::Uri::decode( xMimeType->getParameterValue( aDisplayNameString ), rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); } if( xMimeType->hasParameter( aViewAspectString ) ) |