summaryrefslogtreecommitdiffstats
path: root/desktop
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2017-04-21 22:16:39 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2017-05-19 03:43:30 +0200
commita72c3d047fecffe9a7ca175656b4ab9506a1de3f (patch)
treefd4ba4dc2ac683837d7d145ac5ff5ab2e78872d9 /desktop
parentbetter flexibility through configurable updated build directory (diff)
downloadcore-a72c3d047fecffe9a7ca175656b4ab9506a1de3f.tar.gz
core-a72c3d047fecffe9a7ca175656b4ab9506a1de3f.zip
normalize path for updater
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/app/updater.cxx26
1 files changed, 25 insertions, 1 deletions
diff --git a/desktop/source/app/updater.cxx b/desktop/source/app/updater.cxx
index 07f24b48378f..e82e84f41bc6 100644
--- a/desktop/source/app/updater.cxx
+++ b/desktop/source/app/updater.cxx
@@ -56,7 +56,31 @@ const char* pSofficeExeName = "soffice.exe";
OUString normalizePath(const OUString& rPath)
{
- return rPath.replaceAll("//", "/");
+ OUString aPath = rPath.replaceAll("//", "/");
+
+ // remove final /
+ if (aPath.endsWith("/"))
+ {
+ aPath = aPath.copy(0, aPath.getLength() - 1);
+ }
+
+ while (aPath.indexOf("/..") != -1)
+ {
+ sal_Int32 nIndex = aPath.indexOf("/..");
+ sal_Int32 i = nIndex - 1;
+ for (; i > 0; --i)
+ {
+ if (aPath[i] == '/')
+ break;
+ }
+
+ OUString aTempPath = aPath;
+ aPath = aTempPath.copy(0, i) + aPath.copy(nIndex + 3);
+ }
+
+ SAL_DEBUG(aPath);
+
+ return aPath;
}
void CopyFileToDir(const OUString& rTempDirURL, const OUString rFileName, const OUString& rOldDir)