diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2018-10-11 17:51:32 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2018-10-11 20:38:59 +0200 |
commit | 3bc8e2f3ab69adb9196508688e5211dc171add95 (patch) | |
tree | 0a09e08a1b77c345a7e6e89a3e624833524bb7ff /svtools | |
parent | b75e3ded1f73c943fb09f117e476e367ac0c3413 (diff) |
Revert "tdf#120158: fix ImplGetParameterString for typename"
This reverts commit 40e22f1e1bd44a1aa56ff77b82f1306ed1076ebf. See the commit
message of <https://gerrit.libreoffice.org/61684> "tdf#120158: Base
CMimeContentType on INetMIME::scanContentType" why that change is considered a
superior fix compared to the reverted one.
Change-Id: I1a0d77edee5bb18a98890d2021c777bc4c148a26
Reviewed-on: https://gerrit.libreoffice.org/61686
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/misc/transfer.cxx | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/svtools/source/misc/transfer.cxx b/svtools/source/misc/transfer.cxx index b7c2daf062ab..5600107f8eb4 100644 --- a/svtools/source/misc/transfer.cxx +++ b/svtools/source/misc/transfer.cxx @@ -104,25 +104,6 @@ SvStream& WriteTransferableObjectDescriptor( SvStream& rOStm, const Transferable return rOStm; } -// Clean OUString given in parameter -// by returning an other OUString containing only authorized chars -static OUString lcl_getAuthorizedCharsString(const OUString& rInputString) -{ - sal_Bool pToAccept[128]; - for (sal_Bool & rb : pToAccept) - rb = false; - - const char aQuotedParamChars[] = - "()<>@,;:/[]?=!#$&'*+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ^_`abcdefghijklmnopqrstuvwxyz{|}~. "; - - for ( sal_Int32 nInd = 0; nInd < RTL_CONSTASCII_LENGTH(aQuotedParamChars); ++nInd ) - { - sal_Unicode nChar = aQuotedParamChars[nInd]; - if ( nChar < 128 ) - pToAccept[nChar] = true; - } - return rtl::Uri::encode(rInputString, pToAccept, rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8); -} // the reading of the parameter is done using the special service css::datatransfer::MimeContentType, // a similar approach should be implemented for creation of the mimetype string; @@ -140,14 +121,32 @@ static OUString ImplGetParameterString( const TransferableObjectDescriptor& rObj if( !rObjDesc.maTypeName.isEmpty() ) { - // the type name might contain unacceptable characters, encode all of them - aParams += ";typename=\"" + lcl_getAuthorizedCharsString(rObjDesc.maTypeName) + "\""; + aParams += ";typename=\"" + rObjDesc.maTypeName + "\""; } if( !rObjDesc.maDisplayName.isEmpty() ) { // the display name might contain unacceptable characters, encode all of them - aParams += ";displayname=\"" + lcl_getAuthorizedCharsString(rObjDesc.maDisplayName) + "\""; + // this seems to be the only parameter currently that might contain such characters + sal_Bool pToAccept[128]; + for (sal_Bool & rb : pToAccept) + rb = false; + + const char aQuotedParamChars[] = + "()<>@,;:/[]?=!#$&'*+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ^_`abcdefghijklmnopqrstuvwxyz{|}~. "; + + for ( sal_Int32 nInd = 0; nInd < RTL_CONSTASCII_LENGTH(aQuotedParamChars); ++nInd ) + { + sal_Unicode nChar = aQuotedParamChars[nInd]; + if ( nChar < 128 ) + pToAccept[nChar] = true; + } + + aParams += ";displayname=\"" + + rtl::Uri::encode( + rObjDesc.maDisplayName, pToAccept, rtl_UriEncodeIgnoreEscapes, + RTL_TEXTENCODING_UTF8) + + "\""; } aParams += ";viewaspect=\"" + OUString::number(rObjDesc.mnViewAspect) @@ -188,7 +187,7 @@ static void ImplSetParameterString( TransferableObjectDescriptor& rObjDesc, cons if( xMimeType->hasParameter( aTypeNameString ) ) { - rObjDesc.maTypeName = ::rtl::Uri::decode( xMimeType->getParameterValue( aTypeNameString ), rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); + rObjDesc.maTypeName = xMimeType->getParameterValue( aTypeNameString ); } if( xMimeType->hasParameter( aDisplayNameString ) ) @@ -1202,9 +1201,8 @@ void TransferableDataHelper::FillDataFlavorExVector( const Sequence< DataFlavor if( !rFlavor.MimeType.isEmpty() ) xMimeType = xMimeFact->createMimeContentType( rFlavor.MimeType ); } - catch( const css::uno::Exception& e) + catch( const css::uno::Exception& ) { - SAL_WARN("svtools.misc", "Something went wrong with calling to createMimeContentType: \"" << e << "\""); } aFlavorEx.MimeType = rFlavor.MimeType; |