deltachat / deltachat-desktop

Email-based instant messaging for Desktop.
GNU General Public License v3.0
907 stars 167 forks source link

HTML email view: Some links don't open browser #4017

Open Simon-Laux opened 1 month ago

Simon-Laux commented 1 month ago

More specifically, links without a schema, like academy.qt.io/enrollments

Expected: Open link in system browser Actual: Opening opens a blank page in the html viewer.

Tracking down the problem & Solution ideas

Foundation knowledge

The html email window has two parts: the ui and a sandboxed browser view with disable JS in which the html email is loaded.

Email source is loaded from the email:// scheme that is implemented in https://github.com/deltachat/deltachat-desktop/blob/ba6534b3a9d60ad3e602f770ba630849cc62b87c/src/main/windows/html_email.ts#L412-L420

The http/s handlers are overwritten by handlers that call the http request method of DC core, if allow_remote_content is activated.

Then there is link handling:

https://github.com/deltachat/deltachat-desktop/blob/ba6534b3a9d60ad3e602f770ba630849cc62b87c/src/main/windows/html_email.ts#L472-L493

This openLink function is called in two cases:

seems this is not enough to catch this case. I suspect it tries to open it via the email:// scheme, so we might need to check if it is a domain that is tried to be opened instead of index.html.

concerns:

If you want or need dev tools for the email content add this to the code in html_email.ts.

sandboxedView.webContents.openDevTools()
farooqkz commented 1 month ago

@Simon-Laux Thank you so much for the details :)

farooqkz commented 1 month ago

Okay after investigating, other than Simon's findings, I can also confirm that it's not http, https, file or email protocols either.

farooqkz commented 1 month ago

This does not trigger either when clicking on the link: https://www.electronjs.org/docs/latest/api/web-contents#event-will-frame-navigate