Comments (3)
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.
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.
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)
- Error signing request to Elasticsearch service HOT 1
- Request to sign nuget package HOT 12
- How to create PostAsync as it requires either string or request uri as parameter HOT 1
- Issue create signing request with param HOT 3
- request.Content Headers dropped HOT 3
- AWS4 RequestSigner does not contain a constructor that takes 3 arguments HOT 1
- support idisposable HOT 1
- Getting 403 Forbidden
- Always return forbidden HOT 1
- working example? HOT 3
- excaping issue HOT 3
- Suggestion: HexConverter.ToString() HOT 2
- I have a deadlock issue, when multiple threads try to call the .Sign() method, what could be the issue? HOT 2
- .Net Core compatibility HOT 2
- Wrong canonical string created while trying multiple comma separated values in IncludedData HOT 14
- The request signature we calculated does not match the signature you provided HOT 1
- Content Type not Tracking HOT 2
- forbidden error HOT 1
- Suggestion for dealing with spaces in url HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-signer-v4-dot-net.