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

Spec: split up response validation into two stages, and fix a bug in it #1175

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

morlovich
Copy link
Collaborator

@morlovich morlovich commented May 15, 2024

We will need to do checking in two stages for script bodies to get the proper cross-site seller signals behavior.

While at it, make sure we actually check that the response is a 2xx; we are not supposed to be trying to use error pages.
Also fix the charset check, we accept very few.

Make the WASM path go through this, too, so it actually checks its mimetype, and gets the status check as well.


Preview | Diff

We will need to do checking in two stages for script bodies to get the
proper cross-site seller signals behavior.

While at it, make sure we actually check that the response is a 2xx;
we are not supposed to be trying to use error pages. Also make the WASM
path go through this, too, so it gets this check as well.
@morlovich morlovich requested a review from qingxinwu May 15, 2024 14:32
@qingxinwu qingxinwu added the spec Relates to the spec label May 16, 2024
@morlovich
Copy link
Collaborator Author

Ping @qingxinwu?

Copy link
Collaborator

@qingxinwu qingxinwu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, got a few github notifications and lost track of which needed my attention.

spec.bs Outdated Show resolved Hide resolved
spec.bs Outdated Show resolved Hide resolved
spec.bs Outdated Show resolved Hide resolved
Copy link
Collaborator

@qingxinwu qingxinwu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM % one nit.
Thanks for the fix.

@morlovich morlovich requested a review from miketaylr May 24, 2024 17:50
spec.bs Outdated Show resolved Hide resolved
spec.bs Outdated
"`application/wasm`".

Note: This was intended to match the behavior of [=compiling a potential WebAssembly
response=], but diverges by failing to remove leading and trailing HTTP whitespace.
Copy link
Collaborator

@qingxinwu qingxinwu May 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use [=HTTP tab or space=] since that's what [=get, decode, and split=] (called by extract a mime type).

HTTP whitespace contains U+000A LF, U+000D CR, and [=HTTP tab or space=], so it's different.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, the removal is motivated by https://webassembly.github.io/spec/web-api/#compile-a-potential-webassembly-response step 4 (which probably is motivated by proper parsing)

Changed to http tab or space, thanks.

I am not sure on changing our code simply because we're supposed to be super-conservative about backwards compatibility (and the change can break things by making wasm load when it failed to before), but it is a reasonable thing to consider changing in the code in my book since things that break would break would do so because they were doing something silly, not something reasonable.

@morlovich morlovich requested review from domfarolino and removed request for miketaylr June 3, 2024 14:39
spec.bs Outdated
1. If |mimeType| is not "`application/wasm`":
1. Let |mimeTypeCharset| be |headerMimeType|'s [=MIME type/parameters=]["`charset`"].
1. Return false if any of the following conditions hold:
* |mimeTypeCharset| does not [=map/exist=], or |mimeTypeCharset| is "utf-8", and |responseBody|
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is really weird to use [=map/exist=] anywhere away from the exact location where we pull the entry, even though I can technically understand the intent. For example, in https://infra.spec.whatwg.org/#example-map-get we only ever have map["test"] without "exists" following it after we check "exists" first, so I would try and move the "exists" condition up above to where we try and pull the value out.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Also noticed this had a logic error in that we don't actually accept things other than utf-8 or us-ascii, and fixed that.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't seem done.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might help if I commit and push....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spec Relates to the spec
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants