Skip to content

Commit

Permalink
Fix delimited text delimiter encoding on windows
Browse files Browse the repository at this point in the history
when importing old projects, delimiter might be unencoded.

Fix #48587
  • Loading branch information
elpaso authored and nyalldawson committed Feb 21, 2023
1 parent 1d18260 commit 0c14b2f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/core/qgspathresolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#include <QUrl>
#include <QUuid>

#if defined(Q_OS_WIN)
#include <QRegularExpression>
#endif

typedef std::vector< std::pair< QString, std::function< QString( const QString & ) > > > CustomResolvers;
Q_GLOBAL_STATIC( CustomResolvers, sCustomResolvers )
Expand Down Expand Up @@ -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( '\\', '/' );

Expand Down

0 comments on commit 0c14b2f

Please sign in to comment.