summaryrefslogtreecommitdiff
path: root/sfx2/qa
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-02-22 21:07:34 +0100
committerMiklos Vajna <vmiklos@collabora.com>2021-02-23 09:03:55 +0100
commitaaf7fe0326b3be088a5440525363317fb3d0f158 (patch)
treecc3cfcb54b89f2b0302a83d191b75d895155b705 /sfx2/qa
parentb2111e0060b2ed58d2e2d0ec0d22ba049259f89d (diff)
sfx2 store: fix export to PDF when dir name is URL-encoded
Regression from commit 5259ab8104cfba60c40748ed0cd59d93df038c5b (sfx2 store: create temp files next to local files, 2018-01-08), the problem was that the directory hosting the input ODT file was called "Bugzilla%C3%BF" (URL-encoded from "ÿ"), we got this as "Bugzilla%25C3%25BF" (encoded from directory name), but we forgot to decode it before passing this URL to the utl::TempFile ctor as a parent directory, which resulted in failing to save as PDF, and crashing on DOCX export. Note that in practice this only caused a problem on Windows. Change-Id: I5fc8a356b63efc2f16405a14ee59a061b52c5205 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111359 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sfx2/qa')
-rw-r--r--sfx2/qa/cppunit/doc.cxx31
1 files changed, 31 insertions, 0 deletions
diff --git a/sfx2/qa/cppunit/doc.cxx b/sfx2/qa/cppunit/doc.cxx
index 01e8fd7f2000..058bf4788d67 100644
--- a/sfx2/qa/cppunit/doc.cxx
+++ b/sfx2/qa/cppunit/doc.cxx
@@ -17,6 +17,9 @@
#include <comphelper/propertyvalue.hxx>
#include <sfx2/objsh.hxx>
#include <sfx2/sfxbasemodel.hxx>
+#include <unotools/tempfile.hxx>
+#include <sfx2/docfile.hxx>
+#include <osl/file.hxx>
using namespace com::sun::star;
@@ -74,6 +77,34 @@ CPPUNIT_TEST_FIXTURE(Test, testNoGrabBagShape)
// which was not caught later, resulting in a crash.
pObjectShell->GetSignPDFCertificate();
}
+
+CPPUNIT_TEST_FIXTURE(Test, testTempFilePath)
+{
+ // Create a test file in a directory that contains the URL-encoded "testÿ" string.
+ getComponent() = loadFromDesktop("private:factory/swriter");
+ auto pBaseModel = dynamic_cast<SfxBaseModel*>(getComponent().get());
+ CPPUNIT_ASSERT(pBaseModel);
+ OUString aTargetDir
+ = m_directories.getURLFromWorkdir(u"CppunitTest/sfx2_doc.test.user/test%25C3%25Bf");
+ osl::Directory::create(aTargetDir);
+ OUString aTargetFile = aTargetDir + "/test.odt";
+ css::uno::Sequence<css::beans::PropertyValue> aArgs{ comphelper::makePropertyValue(
+ "FilterName", OUString("writer8")) };
+ pBaseModel->storeAsURL(aTargetFile, aArgs);
+ getComponent()->dispose();
+
+ // Load it and export to PDF.
+ getComponent() = loadFromDesktop(aTargetFile);
+ pBaseModel = dynamic_cast<SfxBaseModel*>(getComponent().get());
+ OUString aPdfTarget = aTargetDir + "/test.pdf";
+ css::uno::Sequence<css::beans::PropertyValue> aPdfArgs{ comphelper::makePropertyValue(
+ "FilterName", OUString("writer_pdf_Export")) };
+ // Without the accompanying fix in place, this test would have failed on Windows with:
+ // An uncaught exception of type com.sun.star.io.IOException
+ // because we first tried to create a temp file next to test.odt in a directory named
+ // "test%25C3%25Bf" instead of a directory named "test%C3%Bf".
+ pBaseModel->storeToURL(aPdfTarget, aPdfArgs);
+}
}
CPPUNIT_PLUGIN_IMPLEMENT();