[ https://issues.apache.org/jira/browse/OLINGO-1571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17579218#comment-17579218 ]
mibo commented on OLINGO-1571: ------------------------------ After checking with OLINGO-1378 and the comment from [~RalfHandl] and the [Overview part of the OData ABNF Construction Rules|https://github.com/oasis-tcs/odata-abnf/blob/main/abnf/odata-abnf-construction-rules.txt#L48-L53] I think the behavior of the {{SearchTokenizer}} must be changed. Reason is that the {{SearchTokenizer}} in Olingo assumes that the SearchPhrase or SearchWord are still percent encoded. But as it is used in Olingo the SearchPhrase or SearchWord are already percent decoded. See {{Parser}} -> parseUri(); line 103 where the {{UriDecoder.splitAndDecodeOptions(query)}} is called. > $search does not allow some special characters in search phrase > --------------------------------------------------------------- > > Key: OLINGO-1571 > URL: https://issues.apache.org/jira/browse/OLINGO-1571 > Project: Olingo > Issue Type: Bug > Components: odata4-server > Affects Versions: (Java) V4 4.9.0 > Reporter: Matthias Schur > Assignee: mibo > Priority: Major > Attachments: OLINGO-1571.patch > > Time Spent: 10m > Remaining Estimate: 0h > > OLINGO 4 $search requires double encoding of some chars in search phrases. > The [OData > ABNF|https://github.com/oasis-tcs/odata-abnf/blob/99d6836d59f51fdd75cc9484bea3f537a098015f/abnf/odata-abnf-construction-rules.txt#L350] > requires certain special chars such as *&* to be percent-encoded in search > phrases: > {code:java} > searchPhrase = quotation-mark 1*( qchar-no-AMP-DQUOTE / SP ) quotation-mark > qchar-no-AMP-DQUOTE = unreserved / pct-encoded-no-DQUOTE / other-delims / ":" > / "@" / "/" / "?" / "$" / "'" / "="{code} > However, Olingo > [decodes|https://github.com/apache/olingo-odata4/blob/4.9.0/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java#L103] > search options before parsing, e.g. the search phrase *"bike %26 car"* is > encoded to *%22bike%20%26%20car%22* and decoded to *"bike & car"* before > parsing the search phrase. This results in an exception *'Forbidden character > in state PHRASE->&’.* > Workaround: Double encode special characters in search phrases. > {code:java} > http://host/service/Products?$search="bike %2526 car" {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)