diff options
| author | Danilo M. <danix@danix.xyz> | 2026-08-03 09:43:07 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-08-03 09:43:07 +0200 |
| commit | 5de81471ebcac21dbf8c5d781cd1b5f1df931bb8 (patch) | |
| tree | 785b57c48190602a521bed871ca9242a1f6d3fd9 /src/messageview.cpp | |
| parent | cf17e6126c6487527a1fd1ff2c078e7637c92118 (diff) | |
| download | qtmaildir-5de81471ebcac21dbf8c5d781cd1b5f1df931bb8.tar.gz qtmaildir-5de81471ebcac21dbf8c5d781cd1b5f1df931bb8.zip | |
fix: render the message pane at all
Clicking a thread left the pane blank. Two independent bugs, both from the
same false premise: that setHtml() navigates to the base URL it is given.
It does not. setHtml() navigates to a data: URL carrying the markup and
applies the base URL afterwards, purely as the document's origin. Verified
empirically on Qt 6.11.
Built on that wrong assumption were:
- MessagePage::acceptNavigationRequest compared the navigation's URL
against documentUrl() and rejected everything else, so the document load
was refused. It now accepts a typed main-frame navigation, which is one
we initiated ourselves.
- RequestInterceptor exempted exactly the qtmaildir: base URL and denied
everything else, so the data: document load was blocked too.
The interceptor fix is scoped to ResourceTypeMainFrame rather than allowing
the data: scheme outright. A blanket allow would have been a real hole: a
message body can write <img src="data:..."> or an iframe, and the existing
dataSchemeBlocked test in test_interceptor.cpp was right to fail when that
was tried. Sub-resource data: URLs remain denied.
Note this was never working. The drafted version had the same defect in a
different spelling (it compared url.scheme() rather than the whole URL, and
would have rejected the data: navigation just the same), and task 11 shipped
with no runtime test to catch it. test_messageview.cpp now pins all three
facts: the document loads, its text reaches the page, and a data: image
inside a hostile body stays blocked.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'src/messageview.cpp')
| -rw-r--r-- | src/messageview.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/messageview.cpp b/src/messageview.cpp index 4e7586e..f8dc4ab 100644 --- a/src/messageview.cpp +++ b/src/messageview.cpp @@ -31,10 +31,18 @@ protected: bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame) override { - // setHtml() arrives as a typed navigation to our own base URL. Matching - // the exact URL rather than the scheme keeps this consistent with the - // interceptor, which deliberately refuses to trust qtmaildir: wholesale. - if (type == NavigationTypeTyped && url == MessageView::documentUrl()) + // setHtml() does NOT navigate to the base URL it is given: it + // navigates to a data: URL carrying the markup, and applies the base + // URL afterwards as the document's origin. Verified empirically on Qt + // 6.11; an earlier version of this function compared against + // documentUrl() here and rejected every document load, so nothing + // rendered at all. + // + // A typed main-frame navigation is therefore one we initiated + // ourselves, and is accepted on that basis. This is not the security + // boundary: RequestInterceptor still vets every request the document + // goes on to make, including the qtmaildir: origin itself. + if (type == NavigationTypeTyped && isMainFrame) return true; if (type == NavigationTypeLinkClicked) { |
