summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2019-07-10 08:31:39 -0400
committerAndras Timar <andras.timar@collabora.com>2020-05-15 14:12:50 +0200
commit7a831d5139f30bad2468323a74850810ada136cd (patch)
treef4a16afcc5e95b29ec1306f0e53c1e221c1cca68
parentee643e3b61c234b0c209d261c21fe9f7f0e0d692 (diff)
sw: fail loading when the fallback text detection fails
When we document in question fails to match any known type, we try to open as plain text (and convert to a Writer doc). However we should not display non-text when we have failed to detect ascii or unicode contents in the file. This happens with corrupted documents, for example, where we end up displaying non-printable binary data. Change-Id: Iccc158a4cb6051a8b17ba01987a30a9882a27fa9 Reviewed-on: https://gerrit.libreoffice.org/75512 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Jan Holesovsky <kendy@collabora.com> (cherry picked from commit d1f6f27e2a014aa55e2762f1209dc520fb183404) Reviewed-on: https://gerrit.libreoffice.org/78452 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/82099 Tested-by: Jenkins Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r--sw/source/filter/ascii/parasc.cxx6
1 files changed, 5 insertions, 1 deletions
diff --git a/sw/source/filter/ascii/parasc.cxx b/sw/source/filter/ascii/parasc.cxx
index cbdae221ed1e..95948041d767 100644
--- a/sw/source/filter/ascii/parasc.cxx
+++ b/sw/source/filter/ascii/parasc.cxx
@@ -260,7 +260,11 @@ ErrCode SwASCIIParser::ReadChars()
nOrig = nLen = rInput.ReadBytes(pArr.get(), ASC_BUFFLEN);
rtl_TextEncoding eCharSet;
LineEnd eLineEnd;
- bool bRet = SwIoSystem::IsDetectableText(pArr.get(), nLen, &eCharSet, &bSwapUnicode, &eLineEnd);
+ const bool bRet
+ = SwIoSystem::IsDetectableText(pArr.get(), nLen, &eCharSet, &bSwapUnicode, &eLineEnd);
+ if (!bRet)
+ return ERRCODE_IO_BROKENPACKAGE;
+
OSL_ENSURE(bRet, "Autodetect of text import without nag dialog must have failed");
if (bRet && eCharSet != RTL_TEXTENCODING_DONTKNOW)
{