Giter Site home page Giter Site logo

Comments (3)

tsibelman avatar tsibelman commented on September 26, 2024 1

Hi, thanks for the contribution but that was not a mistake. It was a real case I encountered.

Consider URLs in the form of
https://www.test.com/?param

Folowing code will print "Key is:null value is:param"
var paramCollection=HttpUtility.ParseQueryString(new Uri("https://www.test.com/?param").Query);
Console.WriteLine("Key is:"+(paramCollection.AllKeys[0]??"null")+" value is:"+paramCollection.GetValues(0)[0]);

from aws-signer-v4-dot-net.

alex-piccione avatar alex-piccione commented on September 26, 2024

I see the difference now, thanks for the example.
The "Handles keys without values" didn't make me think about that scenario.
For the benefit of other readers:
?param is parsed as a null key with "param" value
?param= is parsed as "param" key with null value

So, the querystring parser is consideringnull the key and "param" the value, but the code (in the key == null branch) is doing the other way (using the value "param" as key name and setting null/empty the value):
values.Add(Uri.EscapeDataString(querystring[key]), new[] { $"{Uri.EscapeDataString(querystring[key])}=" });
that is "param" the key and null the value.

A quick test:
string url = "https://www.test.com/?aaa=1&aaa=2&value1&value2";
result in:
querystring[0] (key = "aaa"): "1,2"
querystring[1] (key is null) : "value1,value2"

I'm not saying it is wrong or not working, just an analysis to understand the behavior.

from aws-signer-v4-dot-net.

tsibelman avatar tsibelman commented on September 26, 2024

I think it very weird way of handling such cases if I would design NameValueCollection I would handling key and key= cases as the same one instead of treating one as key without value and the other as value without the key, but this an option we have right now.

from aws-signer-v4-dot-net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.