Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux blank screen fix #3065

Merged
merged 2 commits into from
Nov 22, 2024
Merged

Linux blank screen fix #3065

merged 2 commits into from
Nov 22, 2024

Conversation

benma
Copy link
Contributor

@benma benma commented Nov 22, 2024

The only "problem" left is that the console logs

Please register the custom scheme 'bitboxapp' via QWebEngineUrlScheme::registerScheme() before installing the custom scheme handler.

But it seems to work anyway. I couldn't figure out how to get rid of this message.

Fixes BitBoxSwiss#2684 and hopefully BitBoxSwiss#3061.

Without this, on linux the local mimetype database (influenced by
various packages installed on the system) can mess with the mimetype
resolution of our .html/.js/.css files served locally, resulting in a
blank page.

This manually intercepts local requests and forces the correct
mimetype for a set of hardcoded extensions.
hardcodedMimeType = "text/css";
} else if (path.endsWith(".svg")) {
hardcodedMimeType = "image/svg+xml";
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only ones missing as far as I see are .webm (for the password input video) and .png

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls provide the mimetypes.

The only practical isues we had were with .html and .js, the others I put just in case but are not fixing any known bugs, so it's not important to add all of them right away.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in chromium

  • ".png" shows "image/png"
  • ".webm" uses "video/webm"

I didn't find any other endings in frontends/web/build

Copy link
Collaborator

@Beerosagos Beerosagos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on Linux after reproducing the issue. Works for me: the app loads, the back navigation seems intact and Moonpay widget loads as expected.

Just need to update one more line for the new version.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CURRENT_PROJECT_VERSION should be updated too :)

public:
// Similar like the built-in qrc scheme handler, but with hardcoded mime-types.
// https://github.com/qt/qtwebengine/blob/v6.2.4/src/core/net/qrc_url_scheme_handler.cpp
void requestStarted(QWebEngineUrlRequestJob *request) override {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably not very relevant, but I asked Chat to review the function, and he suggested sanitizing the path to avoid accessing files outside the app's scope. Wdyt?

Security Considerations:

The path variable is directly appended to the qrc prefix. Ensure that the URL path is sanitized to prevent potential path traversal attacks, even though the qrc mechanism limits direct filesystem access.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, the original qrc handler does nothing of the sort either:

https://github.com/qt/qtwebengine/blob/v6.2.4/src/core/net/qrc_url_scheme_handler.cpp

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chat says it's part of the fileInfo call, but I can't find any proof in the Qt docs.

@benma benma merged commit ab325eb into BitBoxSwiss:release-v4.46.2 Nov 22, 2024
5 of 6 checks passed
@benma benma deleted the mimetype2 branch November 22, 2024 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants