From 0c14b2fb0f531fc79a9005669f0afb26902358bc Mon Sep 17 00:00:00 2001 From: Alessandro Pasotti Date: Wed, 15 Feb 2023 17:00:20 +0100 Subject: [PATCH] Fix delimited text delimiter encoding on windows when importing old projects, delimiter might be unencoded. Fix #48587 --- src/core/qgspathresolver.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/core/qgspathresolver.cpp b/src/core/qgspathresolver.cpp index 05fc976017a1..d371c66283ef 100644 --- a/src/core/qgspathresolver.cpp +++ b/src/core/qgspathresolver.cpp @@ -23,6 +23,9 @@ #include #include +#if defined(Q_OS_WIN) +#include +#endif typedef std::vector< std::pair< QString, std::function< QString( const QString & ) > > > CustomResolvers; Q_GLOBAL_STATIC( CustomResolvers, sCustomResolvers ) @@ -139,6 +142,16 @@ QString QgsPathResolver::readPath( const QString &f ) const } #if defined(Q_OS_WIN) + + // delimiter saved with pre 3.2x QGIS versions might be unencoded + thread_local const QRegularExpression delimiterRe( R"re(delimiter=([^&]+))re" ); + const QRegularExpressionMatch match = delimiterRe.match( srcPath ); + if ( match.hasMatch() ) + { + const QString delimiter = match.captured( 0 ).replace( '\\', QStringLiteral( "%5C" ) ); + srcPath.replace( match.captured( 0 ), delimiter ); + } + srcPath.replace( '\\', '/' ); projPath.replace( '\\', '/' );