Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Commit

Permalink
Parse href in findLinks with QUrl::fromPercentEncoding
Browse files Browse the repository at this point in the history
This allows for both internal and external links containing percent escaped characters to be parsed correctly.
Previously, http://example.com/foo%26bar was parsed as http://example.com/foo%2526bar instead of
http://example.com/foo%26bar (http://example.com/foo&bar). Same issue for other escaped characters.

According to the docs for the QUrl constructor, in it's default parsing using TolerantMode, it'll only
transform %20 back to space, and will treat all other % signs as raw symbols to be encoded.
  • Loading branch information
daveallie committed Nov 15, 2022
1 parent 024b2b2 commit 6308033
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/pdfconverter.cc
Expand Up @@ -566,7 +566,7 @@ void PdfConverterPrivate::findLinks(QWebFrame * frame, QVector<QPair<QWebElement
if (h.startsWith("__WKANCHOR_")) {
local.push_back( qMakePair(elm, h) );
} else {
QUrl href(h);
QUrl href = QUrl(QUrl::fromPercentEncoding(h.toLocal8Bit()), QUrl::StrictMode);
if (href.isEmpty()) continue;
href=frame->baseUrl().resolved(href);
QString key = QUrl::fromPercentEncoding(href.toString(QUrl::RemoveFragment).toLocal8Bit());
Expand Down

0 comments on commit 6308033

Please sign in to comment.