Skip to content

Mongodb: search terms are not escaped before use in rexexp #3754

@rimas-kudelis

Description

@rimas-kudelis

API Platform version(s) affected: master

Description
Searched strings are not properly escaped before being used in Mongodb regular expressions.

How to reproduce
I have an entry containing a string with parentheses (let's say it's foo(bar))in Mongodb, and it appears that I have to escape that string in my HTTP query if I want to find that entry:

http://my.host/my/entities?myField=foo(bar) yields no results, but
http://my.host/my/entities?myField=foo\(bar\) yields all the results expected by performing the first query.

Possible Solution
SearchFilter::addEqualityMatchStrategy() should escape strings before concatenating them to form a regular expression.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions