summaryrefslogtreecommitdiff
path: root/lib/resolve_path.cpp
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:24:35 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:24:35 +0200
commit460091fb0b2ff114cc741372f15bb43b702ea3b1 (patch)
tree0562c2eda4c66969c6e6d0910080db9f5b0def3e /lib/resolve_path.cpp
parent5.15 (diff)
downloadFreeFileSync-460091fb0b2ff114cc741372f15bb43b702ea3b1.tar.gz
FreeFileSync-460091fb0b2ff114cc741372f15bb43b702ea3b1.tar.bz2
FreeFileSync-460091fb0b2ff114cc741372f15bb43b702ea3b1.zip
5.16
Diffstat (limited to 'lib/resolve_path.cpp')
-rw-r--r--lib/resolve_path.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/resolve_path.cpp b/lib/resolve_path.cpp
index bea62da3..bf6f99a2 100644
--- a/lib/resolve_path.cpp
+++ b/lib/resolve_path.cpp
@@ -31,14 +31,15 @@ Zstring resolveRelativePath(const Zstring& relativeName) //note: ::GetFullPathNa
const DWORD bufferSize = 10000;
std::vector<wchar_t> buffer(bufferSize);
- const DWORD charsWritten = ::GetFullPathName(applyLongPathPrefix(relativeName).c_str(), //__in LPCTSTR lpFileName,
+ //don't use long path prefix! does not work with relative paths "." and ".."
+ const DWORD charsWritten = ::GetFullPathName(relativeName.c_str(), //__in LPCTSTR lpFileName,
bufferSize, //__in DWORD nBufferLength,
&buffer[0], //__out LPTSTR lpBuffer,
nullptr); //__out LPTSTR *lpFilePart
if (charsWritten == 0 || charsWritten >= bufferSize) //theoretically, charsWritten cannot be == "bufferSize"
return relativeName; //ERROR! Don't do anything
- return removeLongPathPrefix(Zstring(&buffer[0], charsWritten)); //GetFullPathName() preserves long path prefix -> a low-level detail we don't want to leak out!
+ return Zstring(&buffer[0], charsWritten);
}
#elif defined FFS_LINUX || defined FFS_MAC
@@ -545,11 +546,9 @@ Zstring zen::getFormattedDirectoryName(const Zstring& dirString) // throw()
{
//formatting is needed since functions expect the directory to end with '\' to be able to split the relative names.
- Zstring dirname = expandMacros(dirString);
-
- dirname = expandVolumeName(dirname); //should not block
+ Zstring dirname = dirString;
- //remove leading/trailing whitespace
+ //remove leading/trailing whitespace before allowing misinterpretation in applyLongPathPrefix()
trim(dirname, true, false);
while (endsWith(dirname, Zstr(' '))) //don't remove all whitespace from right, e.g. 0xa0 may be used as part of dir name
dirname.resize(dirname.size() - 1);
@@ -557,6 +556,9 @@ Zstring zen::getFormattedDirectoryName(const Zstring& dirString) // throw()
if (dirname.empty()) //an empty string would later be resolved as "\"; this is not desired
return Zstring();
+ dirname = expandMacros(dirname);
+ dirname = expandVolumeName(dirname); //should not block
+
/*
need to resolve relative paths:
WINDOWS:
bgstack15