-
Notifications
You must be signed in to change notification settings - Fork 87
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
Linux blank screen fix #3065
Conversation
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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this 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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
The only "problem" left is that the console logs
But it seems to work anyway. I couldn't figure out how to get rid of this message.