Special chars in values of query strings
A 3rd additional test case:
- [InlineData("api/debug()")] // no query
- [InlineData("api/debug%28%29")] // encoded debug()
+ [InlineData("api/debug()?special=(\\,*,+,?,|,{,},[,],(,),^,$,.,#, ,)&2=(2)&3=[3]&4={4}")] // with query
The third test has revealed issues within the middleware logic, indicating that this test case is likely to fail. The MergeQueryStringsWithoutDuplicateValues method struggles to handle URLs containing query strings with special characters, such as Regex patterns and reserved URL specification characters. This issue became apparent in release 20.0.0 during the refactoring of the MergeQueryStringsWithoutDuplicateValues method, which aimed to integrate existing and new logic (for example OData filters in query parameters, with bug fixes, with new feature for query string placeholders). Regrettably, the method fails to process special characters in parameter values.
Originally posted by @raman-m in #2150 (comment)
Subject
-
Unit tests
|
[Theory] |
|
[Trait("Bug", "2116")] |
|
[InlineData("api/debug()")] // no query |
|
[InlineData("api/debug%28%29")] // debug() |
|
public async Task ShouldNotFailToHandleUrlWithSpecialRegexChars(string urlPath) |
-
Acceptance tests
|
[Theory] |
|
[Trait("Bug", "2116")] |
|
[InlineData("debug()")] // no query |
|
[InlineData("debug%28%29")] // debug() |
|
public void Should_change_downstream_path_by_upstream_path_when_path_contains_malicious_characters(string path) |
Follow up #2150
Regexconstructor derived from URL query parameter values containing specialRegexchars #2150Special chars in values of query strings
A 3rd additional test case:
The third test has revealed issues within the middleware logic, indicating that this test case is likely to fail. The
MergeQueryStringsWithoutDuplicateValuesmethod struggles to handle URLs containing query strings with special characters, such asRegexpatterns and reserved URL specification characters. This issue became apparent in release 20.0.0 during the refactoring of theMergeQueryStringsWithoutDuplicateValuesmethod, which aimed to integrate existing and new logic (for example OData filters in query parameters, with bug fixes, with new feature for query string placeholders). Regrettably, the method fails to process special characters in parameter values.Originally posted by @raman-m in #2150 (comment)
Subject
Unit tests
Ocelot/test/Ocelot.UnitTests/DownstreamUrlCreator/DownstreamUrlCreatorMiddlewareTests.cs
Lines 614 to 618 in d310508
Acceptance tests
Ocelot/test/Ocelot.AcceptanceTests/Routing/RoutingTests.cs
Lines 1171 to 1175 in d310508