[Libreoffice-commits] core.git: sw/source

Ashod Nakashian (via logerrit) logerrit at kemper.freedesktop.org
Mon Dec 16 14:02:13 UTC 2019


 sw/source/filter/ascii/parasc.cxx |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

New commits:
commit 46f36451e84b8ba86d8b3a8745ebc79edc05a554
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Wed Jul 10 08:31:39 2019 -0400
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Mon Dec 16 15:01:19 2019 +0100

    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 at gmail.com>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    (cherry picked from commit d1f6f27e2a014aa55e2762f1209dc520fb183404)
    Reviewed-on: https://gerrit.libreoffice.org/78452
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/82099
    Tested-by: Jenkins
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/sw/source/filter/ascii/parasc.cxx b/sw/source/filter/ascii/parasc.cxx
index a2c0538ebf9b..abf10c4698e0 100644
--- a/sw/source/filter/ascii/parasc.cxx
+++ b/sw/source/filter/ascii/parasc.cxx
@@ -264,7 +264,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)
         {


More information about the Libreoffice-commits mailing list