Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.7.2, 6.8.0
-
Pixel 4 Emulator (x86_64), API Level 34
-
-
9feccda31 (dev), 1bc5783d4 (6.8)
Description
Code
import QtQuick import QtWebView Window { id: root width: 640 height: 480 visible: true property int idx: 0 property list<string> htmls: [ '<html><body><h1>Hello, World!</h1><p>This is an example of loading HTML content in a WebView.</p></body></html>', '<html><body><span style="color:#ff0000">Hello</span></body></html>', '<html><body><span style="color:ff0000">Hello</span></body></html>' ] Timer { interval: 2000 repeat: true running: true onTriggered: { console.log("Loading index", root.idx) webView.loadHtml(root.htmls[root.idx]) root.idx += 1 if (root.idx >= root.htmls.length) root.idx = 0 } } WebView { id: webView anchors.fill: parent onLoadingChanged: (loadRequest) => { switch (loadRequest.status) { case WebView.LoadStartedStatus: console.log("Loading", loadRequest.url); break case WebView.LoadSucceededStatus: console.log("Succeeded", loadRequest.errorString); break case WebView.LoadSucceededStatus: console.log("Failed", loadRequest.errorString); break default: break } } } }
Outcomes
- Windows loads all 3 pages correctly (Expected)
- Android fails to load the 2nd page (index 1) (Not Expected)
Windows output:
qml: Loading index 0 qml: Loading data:text/html;charset=UTF-8,%3Chtml%3E%3Cbody%3E%3Ch1%3EHello%2C World%21%3C%2Fh1%3E%3Cp%3EThis is an example of loading HTML content in a WebView.%3C%2Fp%3E%3C%2Fbody%3E%3C%2Fhtml%3E qml: Succeeded qml: Loading index 1 qml: Loading data:text/html;charset=UTF-8,%3Chtml%3E%3Cbody%3E%3Cspan style%3D%22color%3A%23ff0000%22%3EHello%3C%2Fspan%3E%3C%2Fbody%3E%3C%2Fhtml%3E qml: Succeeded qml: Loading index 2 qml: Loading data:text/html;charset=UTF-8,%3Chtml%3E%3Cbody%3E%3Cspan style%3D%22color%3Aff0000%22%3EHello%3C%2Fspan%3E%3C%2Fbody%3E%3C%2Fhtml%3E qml: Succeeded
Android output:
D qml : : Loading index 0 D qml : : Loading D qml : : Loading data:text/html;charset=UTF-8,%3Chtml%3E%3Cbody%3E%3Ch1%3EHello, World!%3C/h1%3E%3Cp%3EThis is an example of loading HTML content in a WebView.%3C/p%3E%3C/body%3E%3C/html%3E D qml : : Succeeded D qml : : Loading index 1 D qml : : Loading D qml : : Loading data:text/html;charset=UTF-8,%3Chtml%3E%3Cbody%3E%3Cspan style=%22color:#ff0000%22%3EHello%3C/span%3E%3C/body%3E%3C/html%3E D qml : : Succeeded D qml : : Loading index 2 D qml : : Loading D qml : : Loading data:text/html;charset=UTF-8,%3Chtml%3E%3Cbody%3E%3Cspan style=%22color:ff0000%22%3EHello%3C/span%3E%3C/body%3E%3C/html%3E D qml : : Succeeded
Notes
The Windows data URL for index 1 is:
data:text/html;charset=UTF-8,%3Chtml%3E%3Cbody%3E%3Cspan style%3D%22color%3A%23ff0000%22%3EHello%3C%2Fspan%3E%3C%2Fbody%3E%3C%2Fhtml%3E
The Android data URL for index 1 is:
data:text/html;charset=UTF-8,%3Chtml%3E%3Cbody%3E%3Cspan style=%22color:#ff0000%22%3EHello%3C/span%3E%3C/body%3E%3C/html%3E
In other words, the Android string doesn't encode '=' and '#'
Attachments
For Gerrit Dashboard: QTBUG-129303 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
601193,8 | Fix WebView.loadData* encoding on android | dev | qt/qtwebview | Status: MERGED | +2 | +1 |
602893,2 | Fix WebView.loadData* encoding on android | 6.8 | qt/qtwebview | Status: MERGED | +2 | 0 |