Skip to content
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

[Sharing NG] user/group search term does not work with special chars #8615

Closed
JammingBen opened this issue Mar 11, 2024 · 5 comments
Closed
Labels

Comments

@JammingBen
Copy link
Contributor

Describe the bug

The server responds with a 400 error when requesting users/groups via the graph/v1.0/users (or graph/v1.0/groups) endpoint while using a search term that includes special characters.

Steps to reproduce

  1. Create a group with the name test?
  2. Search for this group with the search term test (https://host.docker.internal:9200/graph/v1.0/groups?%24search=test) -> works fine, the result will be the newly created group
  3. Search for this group with the exact search term test? (https://host.docker.internal:9200/graph/v1.0/groups?%24search=test? or encoded - no difference https://host.docker.internal:9200/graph/v1.0/groups?%24search=test%3F) -> doesn't work

Expected behavior

The server responds with the newly created group test?.

Actual behavior

The server responds with a 400 error: Token '?' is invalid.

@rhafer am I missing something, or is this a valid issue?

@rhafer
Copy link
Contributor

rhafer commented Mar 12, 2024

Hm, that's the github.com/CiscoM31/godata.TokenMatcher choking on the the ?. I am not whether that is actually a bug in go data or the ? needs any special escaping in odata. Still looking ...

@JammingBen
Copy link
Contributor Author

Hm, that's the github.com/CiscoM31/godata.TokenMatcher choking on the the ?. I am not whether that is actually a bug in go data or the ? needs any special escaping in odata. Still looking ...

Don't know if it helps, but it pretty much happens with any special char. Also blanks, e.g. Albert%20Einstein or Albert+Einstein.

@rhafer
Copy link
Contributor

rhafer commented Mar 12, 2024

Yeah, the parser only accepts word characters for search literals:
https://github.com/CiscoM31/godata/blame/master-intersight/search_parser.go#L47

That is probably too strict. But we'd need to check the ODATA spec to be sure.

@rhafer
Copy link
Contributor

rhafer commented Mar 12, 2024

@JammingBen
Digging through https://docs.oasis-open.org/odata/odata/v4.01/cs01/abnf/odata-abnf-construction-rules.txt I just remembered that we already had a similar bug report (#7990).

The behavior of godata is actually correct. You need to quote the search phrase in double quotes if it contains anything else than word characters.

So https://host.docker.internal:9200/graph/v1.0/groups?$search="test?" should work. Which raises the question how to search for something containing ". The quick answer for that is: 🤷 . The spec isn't exactly enlightening on that.

@JammingBen
Copy link
Contributor Author

The behavior of godata is actually correct. You need to quote the search phrase in double quotes if it contains anything else than word characters.

Thanks, this works perfectly fine!

So https://host.docker.internal:9200/graph/v1.0/groups?$search="test?" should work. Which raises the question how to search for something containing ". The quick answer for that is: 🤷 . The spec isn't exactly enlightening on that.

Hmm good point. While it's a valid concern, I'd be fine with leaving it unsolved for now since it's quite the edge case. Web actually has several tests including special characters, however none of them include ".

@rhafer rhafer closed this as completed Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants