-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Fix crash related to unparseable/invalid media resource paths #4194
Fix crash related to unparseable/invalid media resource paths #4194
Conversation
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 seems reasonable to me, but for some reason I have it in my head that the background image could also be a URL to an image on the web. Was that scenario ever possible, and does it still work with this?
I know there are some people who are also using ms-appdata:
paths as their background image, does that still work as well?
Good catch, URLs and |
This seems like a good method of validating resource paths.
@zadjii-msft, I found a pretty clean way of validating resource paths. By constructing a (the build failure seems to be due to some anomalous behavior unrelated to this PR) |
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.
Just a minor issue. Other than that, I think it's good. Thanks!
<data name="InvalidBackgroundImage" xml:space="preserve"> | ||
<value>Found a profile with an invalid "backgroundImage". Defaulting that profile to have no background image. Make sure that when setting a "backgroundImage", the value is a valid file path to an image.</value> | ||
</data> | ||
</root> |
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.
There's a good amount of "changes" here that actually don't exist. Please be sure to fix that.
@carlos-zamora, I removed the weird auto-formatting changes on the |
Nnnnn this crash also happens with the icons for profiles if they're not found too. Can we check that one too or somehow make this check more generic? |
@miniksa, I originally didn't validate/correct icons because it appears that it no longer repros. However, might as well validate/correct invalid icon image paths (the check is painless). The latest commit performs the same checks to icons as background images, and displays this error message: |
Whoa, ok. Something must have changed since a month or two ago when I got crashes for missing icons. Either way, thanks for covering it. |
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.
Looks good to me.
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.
Thanks so much!
It looks like your review comment has been addressed.
WT crashes when an unparseable/invalid `backgroundImage` or `icon` resource path is provided in `profiles.json`. This PR averts the crash by the validating and correcting resource paths as a part of the `_ValidateSettings()` function in `CascadiaSettings`. `_ValidateSettings()` is run on start up and any time `profiles.json` is changed, so a user can not change a file path and avoid the validation step. When a bad `backgroundImage` or `icon` resource path is detected, a warning screen will be presented. References #4002, which identified a consistent repro for the crash. To validate the resource, a `Windows::Foundation::Uri` object is constructed with the path. The ctor will throw if the resource path is invalid. Whether or not this validation method is robust enough is a subject worth review. The correction method for when a bad resource path is detected is to reset the `std::optional<winrt::hstring>` holding the file path. The text in the warning display was cribbed from the text used when an invalid `colorScheme` is used. Whether or not the case of a bad background image file path warrants a warning display is a subject worth review. Ensured the repro steps in #4002 did not trigger a crash. Additionally, some potential backdoor paths to a crash were tested: - Deleting the file of a validated background image file path - Changing the actual file name of a validated background image file path - Replacing the file of a validated background image file path with a non-image file (of the same name) - Using a non-image file as a background image In all the above cases WT does not crash, and instead defaults to the background color specified in the profile's `colorScheme`. This PR does not implement this recovery behavior (existing error catching code does). Closes #2329 (cherry picked from commit 77dd51a)
🎉 Handy links: |
🎉 Handy links: |
Summary of the Pull Request
WT crashes when an unparseable/invalid
backgroundImage
resource path is provided inprofiles.json
. This PR averts the crash by the validating and correctingbackgroundImage
resource paths as a part of the_ValidateSettings()
function inCascadiaSettings
._ValidateSettings()
is run on start up and any timeprofiles.json
is changed, so a user can not change a file path and avoid the validation step.When a bad
backgroundImage
resource path is detected this warning screen is presented:References
#4002 which identified a consistent repro for the crash
PR Checklist
Detailed Description of the Pull Request / Additional comments
To validate the resource, the a
Windows::Foundation::Uri
object is constructed with the path, the ctor will throw if the resource path is invalid. Whether or not this validation method is robust enough is a subject worth review. The correction method for when a bad resource path is detected is to reset thestd::optional<winrt::hstring>
holding the file path.The text in the warning display was cribbed from the text used when an invalid
colorScheme
is used. Whether or not the case of a bad background image file path warrants a warning display is a subject worth review.Validation Steps Performed
Ensured the repro steps in #4002 did not trigger a crash. Additionally some potential backdoor paths to a crash were tested:
In all the above cases WT does not crash, and instead defaults to the background color specified in the profile's
colorScheme
. This PR does not implement this recovery behavior (existing error catching code does).