Skip to content

REST Api SearchCriteria encoding error with %25 'like' requests #18050

@ghost

Description

Summary of the issue
When searching "like" results into products repository through REST API, values starting with % or %25 followed by some characters (e.g. "e" or "a") will give bad results, not as expected and described at "Logical OR search" section here: https://devdocs.magento.com/guides/v2.2/rest/performing-searches.html

Preconditions

Environment: LAMP (Apache 2.4.6, php 7.1.0)
Magento version: 2.2.5
Blank installation with 1 admin user, 1 Category and 1 Product (e.g. named "Educational")

Steps to reproduce

  1. Call REST API to obtain admin token:
    POST GET YOUR_BASE_URL /rest/V1/integration/admin/token
    Parameters: username, password

  2. Call REST API to obtain products with the desired search criteria as follows:
    GET YOUR_BASE_URL /rest/V1/products
    ?searchCriteria[filter_groups][0][filters][0][field]=name
    &searchCriteria[filter_groups][0][filters][0][value]=%edu%
    &searchCriteria[filter_groups][0][filters][0][condition_type]=like

OR

GET YOUR_BASE_URL /rest/V1/products
?searchCriteria[filter_groups][0][filters][0][field]=name
&searchCriteria[filter_groups][0][filters][0][value]=%25edu%25
&searchCriteria[filter_groups][0][filters][0][condition_type]=like

Where "edu" is the desired string.
It's the same with any "e" string + anything else, like "extreme" or "environment".
It seems to happen with many other characters (e.g. "%a" char combination)

Expected result

  1. Would expect % to be accepted or %25 to be encoded to % (as per https://devdocs.magento.com/guides/v2.2/rest/performing-searches.html, "Logical OR" section).
  2. Would expect to receive correct results with like search before and after the "edu" string.

Actual result

  1. It seems that the combination of "e" character after % and even after %25 is not encoded / decoded correctly.
  2. In case you put %e it will return filter_group > filters > value as "?u%", no items.
  3. In case you put %25e it will return a 200 OK response without any object, no items.

See attachments.

screen1
screen2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: CatalogComponent: SearchFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.2.xThe issue has been reproduced on latest 2.2 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions