Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3581

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/81/3581/1

fdo#61820: Avoid crasher when file URL contains unicode bytes.

This is a cherry-pick of 6374df20c2a8378209cce21c0e9689e65b8bd9a2.

Credit goes to Isamu Mogi for pin-pointing exactly what caused the crash
and which commit fixed it on master.

Change-Id: Ic5653c76c8c7d8eb8798a9c4ae0cbc43f0e946e4
---
M sc/Library_scfilt.mk
M sc/source/filter/orcus/xmlcontext.cxx
2 files changed, 30 insertions(+), 5 deletions(-)



diff --git a/sc/Library_scfilt.mk b/sc/Library_scfilt.mk
index bdb99ca..0a849da 100644
--- a/sc/Library_scfilt.mk
+++ b/sc/Library_scfilt.mk
@@ -58,6 +58,7 @@
        svxcore \
        tk \
        tl \
+       ucbhelper \
        utl \
        vcl \
        i18nisolang1 \
diff --git a/sc/source/filter/orcus/xmlcontext.cxx b/sc/source/filter/orcus/xmlcontext.cxx
index ecbf35b..001c8f9 100644
--- a/sc/source/filter/orcus/xmlcontext.cxx
+++ b/sc/source/filter/orcus/xmlcontext.cxx
@@ -14,6 +14,7 @@
 
 #include "svtools/treelistbox.hxx"
 #include "svtools/treelistentry.hxx"
+#include "ucbhelper/content.hxx"
 
 #include <orcus/spreadsheet/import_interface.hpp>
 #include <orcus/xml_structure_tree.hpp>
@@ -21,7 +22,14 @@
 #include <orcus/orcus_xml.hpp>
 #include <orcus/global.hpp>
 
+#include <com/sun/star/ucb/XCommandEnvironment.hpp>
+
 #include <string>
+#include <sstream>
+
+#define BUFFER_SIZE 4096
+
+using namespace com::sun::star;
 
 namespace {
 
@@ -143,6 +151,26 @@
     }
 };
 
+void loadContentFromURL(const OUString& rURL, std::string& rStrm)
+{
+    ucbhelper::Content aContent(
+        rURL, uno::Reference<ucb::XCommandEnvironment>(), 
comphelper::getProcessComponentContext());
+    uno::Reference<io::XInputStream> xStrm = aContent.openStream();
+
+    std::ostringstream aStrmBuf;
+    uno::Sequence<sal_Int8> aBytes;
+    size_t nBytesRead = 0;
+    do
+    {
+        nBytesRead = xStrm->readBytes(aBytes, BUFFER_SIZE);
+        const sal_Int8* p = aBytes.getConstArray();
+        aStrmBuf << std::string(p, p + nBytesRead);
+    }
+    while (nBytesRead == BUFFER_SIZE);
+
+    rStrm = aStrmBuf.str();
+}
+
 }
 
 ScOrcusXMLContextImpl::ScOrcusXMLContextImpl(ScDocument& rDoc, const OUString& rPath) :
@@ -154,12 +182,8 @@
 {
     rParam.maUserDataStore.clear();
 
-    OString aSysPath = ScOrcusFiltersImpl::toSystemPath(maPath);
-    const char* path = aSysPath.getStr();
-
-    // TODO: Use our own stream loading call instead of one from orcus.
     std::string aStrm;
-    orcus::load_file_content(path, aStrm);
+    loadContentFromURL(maPath, aStrm);
 
     if (aStrm.empty())
         return false;

-- 
To view, visit https://gerrit.libreoffice.org/3581
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic5653c76c8c7d8eb8798a9c4ae0cbc43f0e946e4
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Kohei Yoshida <kohei.yoshida@gmail.com>


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.