From f7230b197c0e6da06edb50c8c5006d75e78fd052 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel <tobias.doerffel@gmail.com> Date: Thu, 8 Dec 2016 16:02:33 +0100 Subject: [PATCH] Core: LocalSystem: properly handle Windows UNC paths in Path::shrink() Closes #65. --- lib/src/LocalSystem.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/src/LocalSystem.cpp b/lib/src/LocalSystem.cpp index 82809a67..f9a00777 100644 --- a/lib/src/LocalSystem.cpp +++ b/lib/src/LocalSystem.cpp @@ -1009,8 +1009,15 @@ QString Path::shrink( QString path ) path.replace( QDTNS( QDir::tempPath() ), envVar.arg( "TEMP" ) ); } - return QDTNS( path.replace( QString( "%1%1" ). - arg( QDir::separator() ), QDir::separator() ) ); + // remove duplicate directory separators - however skip the first two chars + // as they might specify an UNC path on Windows + if( path.length() > 3 ) + { + return QDTNS( path.left( 2 ) + path.mid( 2 ).replace( + QString( "%1%1" ).arg( QDir::separator() ), QDir::separator() ) ); + } + + return QDTNS( path ); }