tdf#119890 followup Forbid HOME to be the default dir for templates

affecting tvignaud
f41
Caolán McNamara 6 years ago
parent 0d93f7f78b
commit 11894c4eb1

@ -0,0 +1,74 @@
From 30d696d0a1b43b279a92d387557ade33b9212880 Mon Sep 17 00:00:00 2001
From: Takeshi Abe <tabe@fixedpoint.jp>
Date: Thu, 28 Mar 2019 19:04:30 +0900
Subject: [PATCH] tdf#119890 followup: Forbid HOME to be the default dir
... of user templates
This is kludgy yet better than making innocent users waiting for
the template dialog ~forever as pointed out in the comments in
<https://gerrit.libreoffice.org/#/c/67741/>.
Change-Id: I6dfdc0408effb06cc9175cd976ea6687e52a7136
---
.../backends/desktopbe/desktopbackend.cxx | 21 ++++++++++++-------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/shell/source/backends/desktopbe/desktopbackend.cxx b/shell/source/backends/desktopbe/desktopbackend.cxx
index 5923c6583fb7..4b1d0c44b182 100644
--- a/shell/source/backends/desktopbe/desktopbackend.cxx
+++ b/shell/source/backends/desktopbe/desktopbackend.cxx
@@ -127,7 +127,7 @@ void Default::setPropertyValue(OUString const &, css::uno::Any const &)
static_cast< cppu::OWeakObject * >(this), -1);
}
-OUString xdg_user_dir_lookup (const char *type)
+OUString xdg_user_dir_lookup (const char *type, bool bAllowHomeDir)
{
size_t nLenType = strlen(type);
char *config_home;
@@ -218,16 +218,20 @@ OUString xdg_user_dir_lookup (const char *type)
if (aUserDirBuf.getLength()>0 && !bError)
{
aDocumentsDirURL = aUserDirBuf.makeStringAndClear();
- osl::Directory aDocumentsDir( aDocumentsDirURL );
- if( osl::FileBase::E_None == aDocumentsDir.open() )
- return aDocumentsDirURL;
+ if ( bAllowHomeDir ||
+ (aDocumentsDirURL != aHomeDirURL && aDocumentsDirURL != aHomeDirURL + "/") )
+ {
+ osl::Directory aDocumentsDir( aDocumentsDirURL );
+ if( osl::FileBase::E_None == aDocumentsDir.open() )
+ return aDocumentsDirURL;
+ }
}
/* Use fallbacks historical compatibility if nothing else exists */
return aHomeDirURL + "/" + OUString::createFromAscii(type);
}
-css::uno::Any xdgDirectoryIfExists(char const * type) {
- auto url = xdg_user_dir_lookup(type);
+css::uno::Any xdgDirectoryIfExists(char const * type, bool bAllowHomeDir) {
+ auto url = xdg_user_dir_lookup(type, bAllowHomeDir);
return css::uno::Any(
osl::Directory(url).open() == osl::FileBase::E_None
? css::beans::Optional<css::uno::Any>(true, css::uno::Any(url))
@@ -238,12 +242,13 @@ css::uno::Any Default::getPropertyValue(OUString const & PropertyName)
{
if (PropertyName == "TemplatePathVariable")
{
- return xdgDirectoryIfExists("Templates");
+ // Never pick up the HOME directory as the default location of user's templates
+ return xdgDirectoryIfExists("Templates", false);
}
if (PropertyName == "WorkPathVariable")
{
- return xdgDirectoryIfExists("Documents");
+ return xdgDirectoryIfExists("Documents", true);
}
if ( PropertyName == "EnableATToolSupport" ||
--
2.20.1

@ -54,7 +54,7 @@ Summary: Free Software Productivity Suite
Name: libreoffice Name: libreoffice
Epoch: 1 Epoch: 1
Version: %{libo_version}.2 Version: %{libo_version}.2
Release: 3%{?libo_prerelease}%{?dist} Release: 4%{?libo_prerelease}%{?dist}
License: (MPLv1.1 or LGPLv3+) and LGPLv3 and LGPLv2+ and BSD and (MPLv1.1 or GPLv2 or LGPLv2 or Netscape) and Public Domain and ASL 2.0 and MPLv2.0 and CC0 License: (MPLv1.1 or LGPLv3+) and LGPLv3 and LGPLv2+ and BSD and (MPLv1.1 or GPLv2 or LGPLv2 or Netscape) and Public Domain and ASL 2.0 and MPLv2.0 and CC0
URL: http://www.libreoffice.org/ URL: http://www.libreoffice.org/
@ -244,6 +244,7 @@ Patch4: 0001-rhbz-1687589-KDE4-gpoll_wrapper-can-be-called-with-S.patch
Patch5: 0001-rhbz-1690645-null-deref-of-pEntry-when-GetCurEntry-r.patch Patch5: 0001-rhbz-1690645-null-deref-of-pEntry-when-GetCurEntry-r.patch
Patch6: 0001-rhbz-1690732-basic-font-variation-support.patch Patch6: 0001-rhbz-1690732-basic-font-variation-support.patch
Patch7: 0001-rhbz-1699347-__glibcxx_requires_subscript-enabled-in.patch Patch7: 0001-rhbz-1699347-__glibcxx_requires_subscript-enabled-in.patch
Patch8: 0001-no-home-as-templates.patch
%if 0%{?rhel} %if 0%{?rhel}
# not upstreamed # not upstreamed
@ -2124,6 +2125,9 @@ done
%{_includedir}/LibreOfficeKit %{_includedir}/LibreOfficeKit
%changelog %changelog
* Sat Apr 13 2019 Caolán McNamara <caolanm@redhat.com> - 1:6.2.2.2-4
- tdf#119890 followup Forbid HOME to be the default dir for templates
* Fri Apr 12 2019 Caolán McNamara <caolanm@redhat.com> - 1:6.2.2.2-3 * Fri Apr 12 2019 Caolán McNamara <caolanm@redhat.com> - 1:6.2.2.2-3
- Resolves: rhbz#1699347 __glibcxx_requires_subscript-enabled enabled - Resolves: rhbz#1699347 __glibcxx_requires_subscript-enabled enabled

Loading…
Cancel
Save