summaryrefslogtreecommitdiff
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 02:49:01 +0200
commitd307420b020d7dc59c06764d03a88ea8918cc6bf (patch)
tree31eb0263d900775299b435b79545cb301212cd40
parent937690cf600523154a7a765131e7a9ab6cc4acc5 (diff)
normalize path for updater
-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)