Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
5.6.2, 5.9.1, 5.10, 5.11
-
Windows 10
Description
WebSockets can only be used from so-called standard schemes: http, https, file, ftp, qrc and some others. Attempting to open a WebSocket from a custom scheme results in an immediate CloseEvent with code 1006 Abnormal Closure.
The problem can be worked around by registering the custom scheme as 'standard', however this has the side-effect of changing how Chromium parses and canonicalizes URLs. Using the workarounds below results in Chromium expecting the URLs to have hostnames. For example, both the URLs foo:a/b/c and foo:/a/b/c will be parsed as having the hostname a and path /b/c. The canonicalized form will be foo://a/b/c. Additionally this means that the same-origin policy will be applied to the custom scheme, meaning that a page from foo:a/c might not be allowed to load the resource foo:b/c because they have different "hosts" a & b.
WORKAROUND FOR 5.10 & 5.11
The custom scheme must be registered as standard by patching ContentClientQt::AddAdditionalSchemes:
diff --git a/src/core/content_client_qt.cpp b/src/core/content_client_qt.cpp index 66c63b1b..0c2c54c6 100644 --- a/src/core/content_client_qt.cpp +++ b/src/core/content_client_qt.cpp @@ -321,6 +321,7 @@ std::string ContentClientQt::GetProduct() const void ContentClientQt::AddAdditionalSchemes(Schemes* schemes) { + schemes->standard_schemes.push_back("xxx"); schemes->secure_schemes.push_back(kQrcSchemeQt); }
WORKAROUND FOR 5.9
The custom scheme must be registered as standard by patching Chromium's url library in src/3rdparty:
diff --git a/chromium/url/url_util.cc b/chromium/url/url_util.cc index 0a84d5e23c..38c1b44a00 100644 --- a/chromium/url/url_util.cc +++ b/chromium/url/url_util.cc @@ -19,8 +19,9 @@ namespace url { namespace { -const int kNumStandardURLSchemes = 10; +const int kNumStandardURLSchemes = 11; const SchemeWithType kStandardURLSchemes[kNumStandardURLSchemes] = { + {"xxx", SCHEME_WITHOUT_PORT}, {kHttpScheme, SCHEME_WITH_PORT}, {kHttpsScheme, SCHEME_WITH_PORT}, // Yes, file URLs can have a hostname, so file URLs should be handled as
The previous description of this ticket was referring to a different problem to do with forwards compatibility of profile data (sqlite error).
Attachments
Issue Links
- is duplicated by
-
QTBUG-62067 [QWebEngineView] setHtml with custom baseUrl crashes WebSockets (regression)
- Closed
- relates to
-
QTBUG-56169 Can't register service worker using file:// protocol
- Closed
-
QTBUG-65751 QtWebEngine: Custom url schemes cannot access file urls
- Closed
-
QTBUG-62473 Enable cross origin policy for custom scemes
- Closed
For Gerrit Dashboard: QTBUG-62536 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
225226,5 | Add tests/auto/widgets/origins | 5.11 | qt/qtwebengine | Status: MERGED | +2 | 0 |
226808,3 | Add tests of Web Workers over local and custom schemes | 5.11 | qt/qtwebengine | Status: MERGED | +2 | 0 |
226823,2 | Don't create undeserializable mojo origins | 65-based | qt/qtwebengine-chromium | Status: MERGED | +2 | 0 |
226824,3 | Update tests for "Don't create undeserializable mojo origins" | 5.11 | qt/qtwebengine | Status: MERGED | -2 | 0 |
231530,2 | Test iframes over file scheme in tst_Origins::mixedSchemes | dev | qt/qtwebengine | Status: MERGED | +2 | 0 |
233739,4 | Revert "Allow qrc urls to load local resources." | 67-based | qt/qtwebengine-chromium | Status: MERGED | +2 | 0 |
233740,4 | Revert "Allow using quota management API for non-standard URLs" | 67-based | qt/qtwebengine-chromium | Status: MERGED | +2 | 0 |
233741,4 | Revert "Fix assert on QRC urls" | 67-based | qt/qtwebengine-chromium | Status: MERGED | +2 | 0 |
233742,4 | Revert "Fix loading of blobs which have a qrc:// origin" | 67-based | qt/qtwebengine-chromium | Status: MERGED | +2 | 0 |
233743,4 | Extend url library for WebEngine custom schemes | 67-based | qt/qtwebengine-chromium | Status: MERGED | +2 | 0 |
233744,12 | Add QWebEngineUrlScheme class | dev | qt/qtwebengine | Status: MERGED | -2 | 0 |
235178,1 | Add QWebEngineUrlScheme class | 5.11 | qt/qtwebengine | Status: ABANDONED | 0 | 0 |