Skip to content

Sanitizing selector values for the advanced text search operator (#=) #1234

@teppokoivula

Description

@teppokoivula

I'm having trouble figuring out a way to sanitize user-provided query string that is used in context of the advanced text search operator. The general guideline is that $sanitizer->selectorValue() should be used (and it does, or there's a risk that the query may contain something potentially harmful, or at least "surprising"), yet I haven't found a clean way to make a query such as +"foo bar" or -"foo bar"survive this.

Is this an issue, something that hasn't been implemented (yet?), or perhaps a special case that should be handled in some other way?

Screenshot 2020-08-27 at 10 40 51

I can kind of get this to work if I call selectorValue() with options 'useQuotes' => false, 'version' => 1 and wrap the query string in double quotes, but it seems potentially problematic to rely on V1 (there's no info if this is a permanent option or something that may be deprecated later on), and I'd prefer to avoid custom quote handling.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions