Kaydet (Commit) 3bc8e2f3 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Revert "tdf#120158: fix ImplGetParameterString for typename"

This reverts commit 40e22f1e.  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: 's avatarStephan Bergmann <sbergman@redhat.com>
üst b75e3ded
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment