GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Quote Multipart/Form-Data Field Names by markekraus · Pull Request #6782 · PowerShell/PowerShell Conversation
Contributor
PR Summary
Since There is no decent way to test this as the metadata for text fields is lost when the form is processed in ASP.NET. Only way would be to return the raw request body and parse it with regex. PR Checklist
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Mark Kraus (markekraus)
requested review from
James Truher (JamesWTruher),
Paul Higinbotham (PaulHigin) and
Dan Travison (dantraMSFT)
as code owners
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Steve Lee (SteveL-MSFT)
approved these changes
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Collaborator
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Collaborator
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Collaborator
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Ilya (iSazonov)
previously approved these changes
|
There was an error while loading. Please reload this page.
|
Dongbo Wang (@daxian-dbw) Do you agree that we use the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I don't have a strong opinion. I don't want to block people from using C# language features :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Dongbo Wang (@daxian-dbw) Thanks! Mark Kraus (@markekraus) ConvertTo<T> uses InvariantCulture. I believe we should keep consistency. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Yea. I'm not married to any particular string formater or interpolation method. So, whatever works best. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
We could = "\"" + ... + "\""; |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry for wrong close. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
You can also choose culture with the string interpolation: FormattableString message = $"The speed of light is {speedOfLight:N3} km/s."; string messageInInvariantCulture = FormattableString.Invariant(message); See https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I think that the double formatting superfluous here. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ilya (@iSazonov) Does the culture on these even matter? I'm not doing any format transformations, I'm just shoving one string inside another. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I remember that we have already corrected misuses of culture in formatting. So I'm trying to be careful here. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ilya (@iSazonov) I'm saying that I believe the culture isn't important here because they are already strings when being interpolated and I am not performing any transformations on it. What I understand happens here is is So I'm asking.. does it even matter here? as far as I can tell, what ever string interpolation, concatenation, creation, and building method would all produce the same strings in the end because we are just dealing with combining strings and not doing any formatting or transformations (those are already done by
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
No. The discussion is about code style. Bad style is a open door for camouflaged bugs. Therefore, we require explicit curly braces in the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
... why is this bad style? what is wrong with |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ilya (@iSazonov) Also, I cannot figure out how you intend to use String.Create() here. Can you provide me with an example relevant to this PR? It seems like it is overkill for string concatenation. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I am very sorry for noisy. We had culture related bugs in string operations.
You could ignore this today. I hope we'll do code cleanups to reduce allocations and use the pattern too. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
ok.. so |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
If other maintainers agree that we should always use explicit culture then yes. Previously we use + for concatinations for few arguments (~< 5). Othervise StringBuilder is preferable. In the case I'd use var name = LanguagePrimitives.ConvertTo<String>(fieldName); contentDisposition.Name = String.Create(2+name.Length, name, (Span<char> destination, string str) => { destination[0] = '"'; str.AsSpan().CopyTo(destination.Slice(1)); destination[destination.Length-1] = '"'; }); |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Why? Why always use explicit culture? String concatenation does not require it. It is relvant when doing formatting or transformations, but just combining strings it's senseless.
If this will unblock this PR so it will be merged, I will change it to use
Why? That is a seriously over-complicated verbose and tough to follow piece code just to put |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
We never know exactly what users will do. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
We do know that this is a form submission style that is not as widely adopted as standard forms. We do know that the intended purpose of this submission method is GUI browser based communications. We do know that some APIs do use this for file uploads, but not all. We do know that while there have been asks for this feature to be added, not many. If I didn't have my own personal need for it, it may never have even entered consideration to be adopted in the web cmdlets. Yes, we are not clairvoyant and we cannot know 100% what users will do, but, let's be realistic here: the string concatenation for quoting field names filename values and of this feature is NEVER going to be a performance concern. Especially when it is already associated with slow, long running, and memory intense tasks (uploading data). The few fractions of a millisecond shaved off and memory usage saved by using What I do know for certain is that I will have to look at this code in the future. And very likely, someone else will too. I do know that String.Create() is complex and not easy to read. I do know that I can skim the If you want to add a string concatenation utility method that allows us to abstract |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Forget about
This is not obviously for code reviewer. My first impression was that it evidently. Then there were questions. Why we use formatting if we need quoting? Why we use Summing up this discussion I think |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
In this case, the compiler will translate the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Keith Hill (@rkeithhill) What plugin you use in VS Code to see IL? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
It would be much appreciated if this PR makes it in for Preview3. Just sayin'. :-) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Invoke-WebRequest multipart form-data fails file upload when field names not quoted
There was an error while loading. Please reload this page.