-
Notifications
You must be signed in to change notification settings - Fork 350
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
Fix ArgumentNullException for: $filter=property in [''] #3122
Fix ArgumentNullException for: $filter=property in [''] #3122
Conversation
...EndTests/Tests/Client/Microsoft.OData.Client.E2E.Tests/ClientTests/Tests/ClientQueryTests.cs
Outdated
Show resolved
Hide resolved
...lTests/Microsoft.OData.Core.Tests/ScenarioTests/UriParser/FilterAndOrderByFunctionalTests.cs
Outdated
Show resolved
Hide resolved
@WanjohiSammy
|
I have updated the PR description to reflect correctly that this was failing because the |
@WanjohiSammy Can you confirm what I asked here #3122 (comment) |
@WanjohiSammy I have confirmed that we support brackets, i.e., |
I thought I confirmed here #3122 (comment) -We do support square brackets but in case of empty string in these brackets an exception is thrown. |
Issues
This pull request fixes #3092
Description
This PR addresses an issue where the OData URI parser throws an
ArgumentNullException
when encountering a list with empty string insquare brackets
.For example, the following query will throw an ArgumentNullException:
/People?$filter=Name in ['']
/People?$filter=Name in [ ' ' ]
/People?$filter=Name in [ \"\", ' ' ]
/People?$filter=Name in [ \"\", '' ]
/People?$filter=Name in [\"\"]
/People?$filter=Name in [ \"\", \" \" ]
/People?$filter=Name in [ \"\" ]
/People?$filter=Name in [ '' , ' ' ]
Change
This change ensures the Empty String in
square brackets
are handle the same way asparentheses
when constructingCollectionNode
inGetCollectionOperandFromToken
method. This method calls the following methods to handle Single and Double quotes:ProcessSingleQuotedStringItem
is called to handle single-quoted string items within a collection. This method convertssingle-quoted
strings todouble-quoted
strings, ensuring compatibility with JSON format. It manages the escaping of single quotes by unescaping double single quotes and escaping double quotes. For example, it converts ''' to "" and 'ghi''' to "ghi'"ProcessDoubleQuotedStringItem
is then called to process double-quoted string items within a collection. This method ensures that the string is properly escaped for JSON format, handling the escaping of double quotes and backslashes. For example, it converts "" to "" to avoid passing an empty string to theConstantNode
.Checklist (Uncheck if it is not completed)
Additional work necessary
If documentation update is needed, please add "Docs Needed" label to the issue and provide details about the required document change in the issue.