diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-04-21 22:16:39 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-05-19 03:43:30 +0200 |
commit | a72c3d047fecffe9a7ca175656b4ab9506a1de3f (patch) | |
tree | fd4ba4dc2ac683837d7d145ac5ff5ab2e78872d9 /desktop | |
parent | e8358012c89c980dd6964a82d69bfaeb23a1f5c4 (diff) |
normalize path for updater
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/app/updater.cxx | 26 |
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) |