aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2021-07-09 16:34:46 +0200
committerEike Ziller <eike.ziller@qt.io>2021-07-12 13:01:57 +0000
commit6af5648d1208ed5760d74bd060c74ffa2bcfef6b (patch)
treeff9341663e234cc55488e33b2d497109b295309e
parent908670c5b68d3bcf4712019a028079b8b2042dd4 (diff)
Fix handling of links that only consist of fragment
If a link only consists of a fragment (#something), we must not resolve that relative to the "base" url, which is basically the "path" of the current document. It should be resolved wrt the document URL (including the file name), which we currently don't have available in the container implementation. Just return the fragment unchanged and let the link handler take care of that, like it was before ae2afed543ff2499aab6004394d69684b0911d53. Amends ae2afed543ff2499aab6004394d69684b0911d53 Task-number: QTCREATORBUG-25978 Change-Id: Ibca5f653d107c463a82f538c86aaf607821111bb Reviewed-by: Robert Löhning <robert.loehning@qt.io>
-rw-r--r--src/container_qpainter.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/container_qpainter.cpp b/src/container_qpainter.cpp
index 4a9b14a..ccd2591 100644
--- a/src/container_qpainter.cpp
+++ b/src/container_qpainter.cpp
@@ -1382,8 +1382,11 @@ QUrl DocumentContainerPrivate::resolveUrl(const QString &url, const QString &bas
// relative path: "foo/bar.css"
// server relative path: "/foo/bar.css"
// net path: "//foo.bar/blah.css"
+ // fragment only: "#foo-fragment"
const QUrl qurl(url);
if (qurl.scheme().isEmpty()) {
+ if (url.startsWith('#')) // leave alone if just a fragment
+ return qurl;
const QUrl pageBaseUrl = QUrl(baseUrl.isEmpty() ? m_baseUrl : baseUrl);
if (url.startsWith("//")) // net path
return QUrl(pageBaseUrl.scheme() + ":" + url);