diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2021-09-18 02:08:24 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2021-09-18 17:17:43 +0200 |
commit | 3eb58057b0a936ba76d1a5a587f9bda2dccfe862 (patch) | |
tree | 6904c0a4cd6e3c475b232535a79ed457b965f3cc /comphelper | |
parent | d33338939cb46612d73e6406474006e6ae24fe58 (diff) |
URI-encode DirectoryHelper::scanDirsAndFiles result
All code assumes the result is usable as URI segments.
This fails DirectoryHelper::deleteDirRecursively with files
like org.openoffice.da.hunspell.dictionaries%2Fpage1.xhp,
resulting in an unlimited startup loop after creating a
new user profile via:
$ soffice -env:UserInstallation=file:///tmp/test --safe-mode
$ soffice -env:UserInstallation=file:///tmp/test
So just URI encode all files and directories returned.
This doesn't fix the general problem handling "regular"
DirectoryHelper::deleteDirRecursively failures on startup.
Change-Id: I48aa9816118e19302eb93387bdd741bf27fa7236
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122292
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/misc/DirectoryHelper.cxx | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/comphelper/source/misc/DirectoryHelper.cxx b/comphelper/source/misc/DirectoryHelper.cxx index 4ac2dfe7e829..f444d9450664 100644 --- a/comphelper/source/misc/DirectoryHelper.cxx +++ b/comphelper/source/misc/DirectoryHelper.cxx @@ -11,6 +11,7 @@ #include <sal/config.h> #include <osl/file.hxx> +#include <rtl/uri.hxx> #include <memory> @@ -77,6 +78,11 @@ void DirectoryHelper::scanDirsAndFiles(const OUString& rDirURL, std::set<OUStrin if (osl::FileBase::E_None != aDirectory.open()) return; + auto lcl_encodeUriSegment = [](OUString const& rPath) { + return rtl::Uri::encode(rPath, rtl_UriCharClassUricNoSlash, rtl_UriEncodeIgnoreEscapes, + RTL_TEXTENCODING_UTF8); + }; + osl::DirectoryItem aDirectoryItem; while (osl::FileBase::E_None == aDirectory.getNextItem(aDirectoryItem)) @@ -92,7 +98,7 @@ void DirectoryHelper::scanDirsAndFiles(const OUString& rDirURL, std::set<OUStrin if (!aFileName.isEmpty()) { - rDirs.insert(aFileName); + rDirs.insert(lcl_encodeUriSegment(aFileName)); } } else if (aFileStatus.isRegular()) @@ -103,7 +109,8 @@ void DirectoryHelper::scanDirsAndFiles(const OUString& rDirURL, std::set<OUStrin if (!aFileName.isEmpty()) { - rFiles.insert(std::pair<OUString, OUString>(aFileName, aExtension)); + rFiles.insert(std::pair<OUString, OUString>(lcl_encodeUriSegment(aFileName), + lcl_encodeUriSegment(aExtension))); } } } |