fix: don't re-parse URL unnecessarily when handling dialogs#50062
fix: don't re-parse URL unnecessarily when handling dialogs#50062jkleinsc merged 7 commits intoelectron:mainfrom
Conversation
|
@nmggithub the bots want |
|
@ckerr Apologies for the delay in getting back to you. Honestly, this should apply to any and all branches / versions. It appears to be a long-standing issue. Any cases where its not an issue would likely be different enough to where this diff wouldn't be viable. |
deepak1556
left a comment
There was a problem hiding this comment.
Minor nit, also can you add a crash test case to https://github.com/electron/electron/tree/main/spec/fixtures/crash-cases based on the gist attached to the issue.
jkleinsc
left a comment
There was a problem hiding this comment.
Failing tests need to be addressed.
Just now noticed this. I'll see what I can do, but I think this might also be some of the flakiness of |
Co-authored-by: Robo <hop2deep@gmail.com>
8acc63b to
10b2ab5
Compare
|
Release Notes Persisted
|
|
I have automatically backported this PR to "42-x-y", please check out #50398 |
|
I have automatically backported this PR to "41-x-y", please check out #50399 |
|
I have automatically backported this PR to "39-x-y", please check out #50400 |
|
I have automatically backported this PR to "40-x-y", please check out #50401 |
Description of Change
Should resolve #50059. The crash was due to our code assuming that the frame where a dialog is being shown will always have a parseable URL.
This PR makes two changes:1. it falls back to a generated URL (based on frame identity) when the frame URL is an empty string, and2. it tightens up the origin calculation, falling back to the entire href when, by spec, the
originis a non-uniqueopaque origin (the string"null").The only edge case I see here is if the frame URL is a non-empty string and is un-parsable, but that should be rare. I can add atry-catchif we decide it's worth it.This PR removes an unnecessary
new URL()call that could lead to crashing.Checklist
npm testpassesRelease Notes
Notes: Fixed crash when handling JavaScript dialogs from windows opened with invalid or empty URLs.