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

Add HTTP OWS handling to single range header parsing #1564

Merged
merged 1 commit into from
Feb 20, 2023

Conversation

dlrobertson
Copy link
Member

@dlrobertson dlrobertson commented Dec 10, 2022

Add HTTP optional white space handling to the single range header parser.

Normative changes happen as part of #1520.


Preview | Diff

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

@jakearchibald @youennf @rayankans does any of you think this boolean is worth having for CORS? I think I'd rather allow whitespace in CORS for the Range header so we can keep Range header parsing consistent. In particular this would allow an arbitrary number of 0x09 and 0x20 after bytes=. I don't see the security benefit.

(We also use this parser for blob: URL requests and there we already allow whitespace.)

fetch.bs Outdated
@@ -1243,7 +1243,7 @@ run these steps:

<div algorithm>
<p>To <dfn id=simple-range-header-value>parse a single range header value</dfn> from a
<a>byte sequence</a> <var>value</var>, run these steps:
<a>byte sequence</a> <var>value</var> and a boolean <var>allowWhiteSpace</var>, run these steps:
Copy link
Member

Choose a reason for hiding this comment

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

If we keep this we should name this disallowWhitespace so it can default to false. Although as long as we don't export it we should probably keep it as a required argument.

Copy link
Member Author

Choose a reason for hiding this comment

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

Would this still be the case following the discussion in #1070

@dlrobertson
Copy link
Member Author

@jakearchibald @youennf @rayankans does any of you think this boolean is worth having for CORS? I think I'd rather allow whitespace in CORS for the Range header so we can keep Range header parsing consistent. In particular this would allow an arbitrary number of 0x09 and 0x20 after bytes=. I don't see the security benefit.

(We also use this parser for blob: URL requests and there we already allow whitespace.)

I've tested Blink and WebKit and both disallow the whitespace allowed in HTTP-RANGE as tested here. Would it make sense to remove the boolean, but add a note that some implementations don't allow this optional whitespace?

@annevk annevk added the do not merge yet Pull request must not be merged per rationale in comment label Dec 21, 2022
@annevk
Copy link
Member

annevk commented Dec 21, 2022

It seems that as per more recent discussion in #1070 I misunderstood the ABNF and no whitespace is allowed after bytes= in theory. Let's get to the bottom of that and then revisit this as it might well be that the status quo is correct now.

@dlrobertson dlrobertson force-pushed the single-range-whitespace branch 2 times, most recently from 8561a73 to 0768aac Compare February 5, 2023 17:08
@dlrobertson
Copy link
Member Author

If we keep this we should name this disallowWhitespace so it can default to false. Although as long as we don't export it we should probably keep it as a required argument.

Updated to use disallowWhitespace. Sorry for the delay, I thought I had already done this.

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

This only removes whitespace after = if I understand it correctly. Whereas #1070 (comment) argues for removing it in 6 places.

@dlrobertson dlrobertson force-pushed the single-range-whitespace branch 2 times, most recently from 1be32b3 to bab5f9b Compare February 16, 2023 01:45
@dlrobertson
Copy link
Member Author

HTTP 2616 allowed whitespace:

whitespace supported by parse-single-range
Before =
After =
Before -
After -
Before ,
After ,

Added some extra cases to web-platform-tests/wpt#37569

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

Thanks, that makes sense as we don't support multiple values here. One nit and with that this is good to go.

fetch.bs Outdated Show resolved Hide resolved
Add HTTP optional white space handling to the single range header
parser.
@dlrobertson dlrobertson force-pushed the single-range-whitespace branch from bab5f9b to 8a4f3f8 Compare February 17, 2023 01:43
Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

This looks great, thanks!

Blocked on speced/bikeshed#2476 unfortunately.

@dlrobertson
Copy link
Member Author

Blocked on speced/bikeshed#2476 unfortunately.

No problem! Thanks for the review... Will I need to rebase once the fix for speced/bikeshed#2476 lands?

@annevk
Copy link
Member

annevk commented Feb 17, 2023

No, this is all good. I also looked at #1520 again and apart from invoking this algorithm with true I think that's also good (and I can make that change when merging if it all looks good to you).

@annevk annevk merged commit e4f6c00 into whatwg:main Feb 20, 2023
@annevk annevk removed the do not merge yet Pull request must not be merged per rationale in comment label Feb 20, 2023
@dlrobertson dlrobertson deleted the single-range-whitespace branch February 21, 2023 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants