-
Notifications
You must be signed in to change notification settings - Fork 186
A cookie bug caused a request error (net::ERR_CONNECTION_REFUSED). #606
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
1. `cookie.Name` cannot be assigned an empty string.
2. `cookie.Value` containing comma-separated JSON strings will be truncated into multiple key-value pairs.
cookie string like this:
" "; Location={"country":"","city":" "}
Summary of ChangesHello @colindcli, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses and resolves critical bugs within the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request fixes a bug in cookie parsing where values containing commas (like JSON) were incorrectly split. The change to split cookie strings only by semicolons is correct and is well-supported by the new unit tests. The logic to handle invalid cookie parts by catching exceptions is also a good addition.
I've provided a couple of suggestions for improvement:
- Make the exception handling for invalid cookies more specific to avoid catching unrelated errors.
- Correct a new test case that was asserting incorrect behavior for an invalid cookie name.
Overall, this is a good fix that improves the robustness of cookie parsing.
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.
Pull request overview
This PR addresses cookie parsing issues in HttpListenerRequest: preventing empty-name cookies and avoiding truncation of JSON values containing commas. It adds unit tests and refactors the parser to return a CookieList, splitting only on semicolons to preserve JSON commas and quoting the $Port attribute.
- Refactors ParseCookies to static method returning CookieList and adjusts header handling to use its result.
- Updates cookie tokenization to split only by semicolons; trims tokens and preserves quoted values and JSON.
- Adds comprehensive tests covering version/attributes application, name-only cookies, quoted values, JSON, and port quoting.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/EmbedIO/Net/Internal/HttpListenerRequest.cs | Refactors cookie parsing to return CookieList, changes splitting to semicolons, quotes $Port, and assigns parsed cookies in AddHeader. |
| test/EmbedIO.Tests/Utilities/HttpListenerRequestCookieTest.cs | Adds tests verifying cookie parsing behavior, including JSON value preservation and handling of quoted names/values and attributes. |
Comments suppressed due to low confidence (1)
src/EmbedIO/Net/Internal/HttpListenerRequest.cs:462
- This assignment to e is useless, since its value is never read.
catch (Exception e)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
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.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.
Comments suppressed due to low confidence (1)
src/EmbedIO/Net/Internal/HttpListenerRequest.cs:462
- This assignment to e is useless, since its value is never read.
catch (Exception e)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
cookie.Namecannot be assigned an empty string.cookie.Valuecontaining comma-separated JSON strings will be truncated into multiple key-value pairs.cookie string like this: