Kaydet (Commit) 4b334e45 authored tarafından Mike Kaganski's avatar Mike Kaganski

IsValidFilePath: fix correction of double path delimiters

Wuthout this fix, it had always tried to replace in original path,
thus second occurence of double path delimiter, like in
C:\dir1\\dir2\dir3\\file
would result in invalid path reported.

Change-Id: I63ce97b620229601e18f10016a759275aceeec4d
Reviewed-on: https://gerrit.libreoffice.org/44675Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst 610d909d
......@@ -270,13 +270,15 @@ DWORD IsValidFilePath(rtl_uString *path, DWORD dwFlags, rtl_uString **corrected)
}
/* Now validate each component of the path */
rtl_uString * lastCorrected = path;
while ( bValid && lpComponent )
{
// Correct path by merging consecutive slashes:
if (*lpComponent == '\\' && corrected != nullptr) {
sal_Int32 i = lpComponent - lpszPath;
rtl_uString_newReplaceStrAt(corrected, path, i, 1, nullptr);
rtl_uString_newReplaceStrAt(corrected, lastCorrected, i, 1, nullptr);
//TODO: handle out-of-memory
lastCorrected = *corrected;
lpszPath = (*corrected)->buffer;
lpComponent = lpszPath + i;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment