-
Notifications
You must be signed in to change notification settings - Fork 87
Fix: Process ETag header value to be RFC 9110 compliant. #367
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
Conversation
Enclose ETag header value in double quotes. The following definitions require the ETag header value to be enclosed in double quotes: * RFC 9110 - https://www.rfc-editor.org/rfc/rfc9110#section-8.8.3 ( and previous RFC 7232 - https://www.rfc-editor.org/rfc/rfc7232#section-2.3 ) * MDN docs - https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag#directives
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
willmmiles
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't run any tests, but it looks good to a visual inspection.
Outside the scope of this PR: we might want to factor a short "format-32-bits-as-ETag" function, using either snprintf like src/Webhandlers.cpp:241, OR the hexChars approach in src/AsyncWebServerRequest.cpp:82 -- I don't love that there's two different implementations of this operation in the codebase. (Personally I would favor snprintf as I'm used to valuing code size over CPU time -- that hexChars constant must already be embedded somewhere internally there -- but it's pretty minor either way.)
Yes I saw this duplication when fixing bb0dd46#diff-646b25b11691c11dce25529e3abce843f0ba4bd07ab75ec9eee7e72b06dbf13fR446 The diff is also in the behavior: snprintf adds a null terminator where the hexChars table allows more control and can be used in pretty much any cases. |
You can ask |
|
@StefanOberhumer : this issue being merged, is this fix can wait for the upcoming release (not planned yet), or this can be a blocker in some cases and would then require a release now ? Asking because I don't know how browsers may behave when receiving non compliant etag values... |
I don't think it is a blocker. |
Enclose ETag header value in double quotes.
The following definitions require the ETag header value to be enclosed in double quotes:
RFC 9110 - https://www.rfc-editor.org/rfc/rfc9110#section-8.8.3 ( and previous RFC 7232 - https://www.rfc-editor.org/rfc/rfc7232#section-2.3 )
MDN docs - https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag#directives