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

[Bug]: net.fetch() fails to forward html form submissions intercepted with protocol.handle() #40754

Closed
3 tasks done
BurningEnlightenment opened this issue Dec 13, 2023 · 1 comment · Fixed by #41052
Closed
3 tasks done
Labels
25-x-y 26-x-y 28-x-y 29-x-y bug 🪲 has-repro-gist Issue can be reproduced with code at https://gist.github.com/ platform/windows

Comments

@BurningEnlightenment
Copy link
Contributor

BurningEnlightenment commented Dec 13, 2023

Preflight Checklist

Electron Version

25.9.8, 26.6.2, 28.0.0, 29.0.0-alpha.3

What operating system are you using?

Windows

Operating System Version

Windows 11 Enterprise 22H2 22621.2715

What arch are you using?

x64

Last Known Working Electron version

None--it doesn't work with any electron version shipping protocol.handle().

Expected Behavior

It is documented that if one intercepts a protocol (e.g. given s: Electron.Session s.protocol.handle('http', ...)) one can forward a request to the built-in handler by passing bypassCustomProtocolHandlers: true in the RequestInit parameter.

Actual Behavior

However, if the request originates from a plain html <form> submission, the built-in handler fails with

Error: net::ERR_FAILED
at SimpleURLLoaderWrapper.<anonymous> (node:electron/js2c/browser_init:2:49030)
at SimpleURLLoaderWrapper.emit (node:events:517:28)
(node:9824) electron: Failed to load URL: http://127.0.0.1:3000/ with error: ERR_UNEXPECTED

I observed that the form submission request contains an origin: null header and that removing said header from the request allows the request to succeed. The request also succeeds if no custom protocol handler is installed.

Testcase Gist URL

https://gist.github.com/BurningEnlightenment/83ef1268fa71ebe0fafd9dfa4cc2811f

Additional Information

The Testcase contains an html form which can be submitted to the included koa webserver.

@ckerr ckerr added platform/windows has-repro-gist Issue can be reproduced with code at https://gist.github.com/ 25-x-y 26-x-y 28-x-y 29-x-y labels Dec 13, 2023
@ckerr
Copy link
Member

ckerr commented Jan 3, 2024

CC @nornagon

BurningEnlightenment added a commit to BurningEnlightenment/electron that referenced this issue Jan 18, 2024
zcbenz pushed a commit to BurningEnlightenment/electron that referenced this issue Feb 8, 2024
BurningEnlightenment added a commit to BurningEnlightenment/electron that referenced this issue Feb 14, 2024
jkleinsc pushed a commit that referenced this issue Feb 16, 2024
* refactor(protocol): extract file stream factory

Increase readability by moving the file stream creation logic out of the
`uploadData` to request body conversion function.

* fix: properly flatten streams in `protocol.handle()`

Refs: #39658

* fix: `protocol.handle()` filter null origin header

Refs: #40754

* fix: remove obsolete TODO comment

Refs: #38929

* fix: forward `Blob` parts in `protocol.handle()`

Refs: #40826

* fix: explicitly error out on unknown chunk parts
trop bot added a commit that referenced this issue Feb 16, 2024
Refs: #40754

Co-authored-by: Henrik S. Gaßmann <BurningEnlightenment@users.noreply.github.com>
trop bot added a commit that referenced this issue Feb 16, 2024
Refs: #40754

Co-authored-by: Henrik S. Gaßmann <BurningEnlightenment@users.noreply.github.com>
VerteDinde pushed a commit that referenced this issue Feb 19, 2024
* refactor(protocol): extract file stream factory

Increase readability by moving the file stream creation logic out of the
`uploadData` to request body conversion function.

Co-authored-by: Henrik S. Gaßmann <BurningEnlightenment@users.noreply.github.com>

* fix: properly flatten streams in `protocol.handle()`

Refs: #39658

Co-authored-by: Henrik S. Gaßmann <BurningEnlightenment@users.noreply.github.com>

* fix: `protocol.handle()` filter null origin header

Refs: #40754

Co-authored-by: Henrik S. Gaßmann <BurningEnlightenment@users.noreply.github.com>

* fix: remove obsolete TODO comment

Refs: #38929

Co-authored-by: Henrik S. Gaßmann <BurningEnlightenment@users.noreply.github.com>

* fix: forward `Blob` parts in `protocol.handle()`

Refs: #40826

Co-authored-by: Henrik S. Gaßmann <BurningEnlightenment@users.noreply.github.com>

* fix: explicitly error out on unknown chunk parts

Co-authored-by: Henrik S. Gaßmann <BurningEnlightenment@users.noreply.github.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Henrik S. Gaßmann <BurningEnlightenment@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
25-x-y 26-x-y 28-x-y 29-x-y bug 🪲 has-repro-gist Issue can be reproduced with code at https://gist.github.com/ platform/windows
Projects
No open projects
Status: 👍 Does Not Block Stable
Status: 👍 Does Not Block Stable
Development

Successfully merging a pull request may close this issue.

2 participants