Open WanjohiSammy opened 4 days ago
@WanjohiSammy This change ensures the square brackets are handle the same way as parentheses when constructing CollectionNode in GetCollectionOperandFromToken method:
$filter=Name in ['Sue','Joe']
. Maybe even add a test@gathogojr
- Is use of square brackets in the same manner as parentheses supported by the OData standard?
- Can you confirm that we support non-empty square brackets? For example,
$filter=Name in ['Sue','Joe']
. Maybe even add a test
I have updated the PR description to reflect correctly that this was failing because the empty string
in square brackets
was not handle the same as empty string
in parenthesis
@WanjohiSammy Can you confirm what I asked here https://github.com/OData/odata.net/pull/3122#issuecomment-2485561072
@WanjohiSammy I have confirmed that we support brackets, i.e., Books?$filter=Title in ('Harry Porter')
and Books?$filter=Title in ['Harry Porter']
are both handled fine by the library
@gathogojr
Can you confirm what I asked here #3122 (comment)
I thought I confirmed here https://github.com/OData/odata.net/pull/3122#issuecomment-2485847253 The issue solved by this PR is when there is an empty string in square brackets.
-We do support square brackets but in case of empty string in these brackets an exception is thrown. -Since there is no exception with Empty string in parenthesis, this change ensures empty string in square brackets are treated the same as empty string in parenthesis.
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.