From 927566244fd4592bf45e88e3a154528627fde957 Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Wed, 21 Sep 2022 15:30:36 +0300 Subject: [PATCH] Don't percent-encode local file names while saving an article This commit fixes broken links in complete saved articles to files whose names contain reserved characters. An HTML parser decodes a percent-encoded URL before looking for the referenced file on disk. So a file with a percent-encoded name cannot be found. Percent-encode only the URL to fix the bug. --- mainwindow.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mainwindow.cc b/mainwindow.cc index 22487a69..fdea2925 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -3528,7 +3528,7 @@ static void filterAndCollectResources( QString & html, QRegExp & rx, const QStri { QUrl url( rx.cap( 1 ) ); QString host = url.host(); - QString resourcePath = QString::fromLatin1( QUrl::toPercentEncoding( Qt4x5::Url::path( url ), "/" ) ); + QString resourcePath = Qt4x5::Url::path( url ); if ( !host.startsWith( '/' ) ) host.insert( 0, '/' ); @@ -3545,6 +3545,7 @@ static void filterAndCollectResources( QString & html, QRegExp & rx, const QStri } // Modify original url, set to the native one + resourcePath = QString::fromLatin1( QUrl::toPercentEncoding( resourcePath, "/" ) ); QString newUrl = sep + QDir( folder ).dirName() + host + resourcePath + sep; html.replace( pos, rx.cap().length(), newUrl ); pos += newUrl.length();