diff options
author | Michael Stahl <mstahl@redhat.com> | 2014-11-06 18:32:35 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2014-11-06 18:45:00 +0100 |
commit | ba08fe174660dc4abdda0aec02dc52b9c7fdb7b5 (patch) | |
tree | f8c11d752ee1acfffda22feb1ac33a12f137f2f0 | |
parent | aaccd8560e555d7e3cf062ca3672b77702397a70 (diff) |
filter: use more appropriate conversion from ASCII for arbitrary input
... with unknown encoding, mapping non-ASCII chars to something that
doesn't cause trouble (in FilterDetect::detect()).
Change-Id: Ibf2a2e2fd7c0c00e55042d2ccad173fab7a1b0bd
-rw-r--r-- | filter/source/xmlfilterdetect/filterdetect.cxx | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/filter/source/xmlfilterdetect/filterdetect.cxx b/filter/source/xmlfilterdetect/filterdetect.cxx index a6f0089790e5..b4d614f172cc 100644 --- a/filter/source/xmlfilterdetect/filterdetect.cxx +++ b/filter/source/xmlfilterdetect/filterdetect.cxx @@ -115,7 +115,12 @@ OUString SAL_CALL FilterDetect::detect( com::sun::star::uno::Sequence< com::sun: } if ( nUniPos == 3 || ( nUniPos == 0 && !bTryUtf16 ) ) // UTF-8 or non-Unicode - resultString = OStringToOUString( read_uInt8s_ToOString( *pInStream, nSize ), RTL_TEXTENCODING_UTF8 ); + { + OString const str(read_uInt8s_ToOString(*pInStream, nSize)); + resultString = OUString(str.getStr(), str.getLength(), + RTL_TEXTENCODING_ASCII_US, + RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_DEFAULT|RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT|RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT); + } else if ( nUniPos == 2 || bTryUtf16 ) // UTF-16 resultString = read_uInt16s_ToOUString( *pInStream, nSize ); |