-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add SAPI_HEADER_DELETE_PREFIX
, make ext/session use it
#18678
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
base: master
Are you sure you want to change the base?
Conversation
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.
Happy with the ext/session changes, makes sense to delegate this to the SAPI layer.
SAPI_HEADER_REMOVE_PREFIX
, make ext/session use itSAPI_HEADER_DELETE_PREFIX
, make ext/session use it
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 agree that this logic should be in SAPI.c but it might be better to have more specialized variants (even specifically for Set-Cookie wrapped in SAPI functions.
I would prefer not use header_line but just wrapping functions instead though.
0ef7bff
to
251542b
Compare
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.
Nice, all looks good to me!
The session ext currently munges into the linked list of headers itself, because the delete header API is given the key for headers to delete. The session ext wants to use a prefix past the colon separator, for i.e. "Set-Cookie: PHPSESSID=", to eliminate only the specific cookie rather than all cookies. This changes the SAPI code to add a new header op to take a prefix instead. Call sites are yet unchanged. Also fix some whitespace.
Use the modern SAPI header ops API, including the remove prefix op we just added.
The purpose of this is clear, and after refactoring, the special case is no longer there, so it has no value.
Suggestion from Jakub.
I don't think this needs to be special cased with the parameter.
Suggestion from Jakub.
It may be better to use spaces in here instead.
440f074
to
e2b3ce7
Compare
Made that cosmetic tweak and rebased. |
Refactoring this as part of triaging GH-18601 - I don't think it'll fix the issue, but it's a good idea to clean anyways. ext/session had its own copy of the remove header code, because the SAPI header op mandated it was just a name, and would remove all headers for that name. ext/session couldn't rely on this because it only wanted to remove a specific cookie, not all of them.
To simplify this, add a version of
SAPI_HEADER_DELETE
that is more flexible and allows for passing a prefix to check for, not just a name. This should work for removing a specific cookie from the headers. (Also fixes some whitespace too.)