mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-12-18 07:24:07 +00:00
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.
This commit is contained in:
parent
fb224043a2
commit
927566244f
|
@ -3528,7 +3528,7 @@ static void filterAndCollectResources( QString & html, QRegExp & rx, const QStri
|
||||||
{
|
{
|
||||||
QUrl url( rx.cap( 1 ) );
|
QUrl url( rx.cap( 1 ) );
|
||||||
QString host = url.host();
|
QString host = url.host();
|
||||||
QString resourcePath = QString::fromLatin1( QUrl::toPercentEncoding( Qt4x5::Url::path( url ), "/" ) );
|
QString resourcePath = Qt4x5::Url::path( url );
|
||||||
|
|
||||||
if ( !host.startsWith( '/' ) )
|
if ( !host.startsWith( '/' ) )
|
||||||
host.insert( 0, '/' );
|
host.insert( 0, '/' );
|
||||||
|
@ -3545,6 +3545,7 @@ static void filterAndCollectResources( QString & html, QRegExp & rx, const QStri
|
||||||
}
|
}
|
||||||
|
|
||||||
// Modify original url, set to the native one
|
// Modify original url, set to the native one
|
||||||
|
resourcePath = QString::fromLatin1( QUrl::toPercentEncoding( resourcePath, "/" ) );
|
||||||
QString newUrl = sep + QDir( folder ).dirName() + host + resourcePath + sep;
|
QString newUrl = sep + QDir( folder ).dirName() + host + resourcePath + sep;
|
||||||
html.replace( pos, rx.cap().length(), newUrl );
|
html.replace( pos, rx.cap().length(), newUrl );
|
||||||
pos += newUrl.length();
|
pos += newUrl.length();
|
||||||
|
|
Loading…
Reference in a new issue