-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Remove quotes from MultipartReader boundary #41308
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
74754ba
Added unit test that accepts a Boundary with quotes to make sure no e…
aclark09 344667d
Remove quotes from incoming boundary in the MultipartReader constructor
aclark09 293d34b
Organize code by moving boundary variable cleanup to line before it's…
aclark09 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
Organization: Move this down to where _boundary is being initialized.
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.
So just put it right above that line? Yeah I can do that.
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.
Does this allocate when there's nothing to do?
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.
Are you talking about that fact that RemoveQuotes is called before all of the null checks? I just pushed up a change so that it's now being called right before the boundary variable is actually used, so it shouldn't be allocated unless it's used now.
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.
It doesn't allocate.
aspnetcore/src/Http/Headers/src/HeaderUtilities.cs
Lines 570 to 574 in bcdb13d
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.
Have you checked if there is no string allocation when calling ToString() when double quotes are not present in an input boundary? What about checking if there are double quotes first and only after that to remove them and call ToString()?
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 checked, there's no allocation since this ends up returning the whole original string.
https://github.com/dotnet/runtime/blob/2ea67f1f42e8170676c9e9591a974e39513390db/src/libraries/Microsoft.Extensions.Primitives/src/StringSegment.cs#L661
https://github.com/dotnet/runtime/blob/2ea67f1f42e8170676c9e9591a974e39513390db/src/libraries/Microsoft.Extensions.Primitives/src/StringSegment.cs#L81
https://github.com/dotnet/runtime/blob/215b39abf947da7a40b0cb137eab4bceb24ad3e3/src/libraries/System.Private.CoreLib/src/System/String.Manipulation.cs#L1831-L1834
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.
Thanks for the clarification