Skip to content

Add a helper function to escape filters correctly #49

Description

@alexander-schranz

Description

If have something like:

$query = 'tags = ' . $filter;

The filter need to be escaped. Normally I would expect something like:

$query = 'tags = ' . addslashes($filter);

but that is not true was && is used. So it need to be also added to escaping. I currently did go with:

$query = 'tags = "' . addcslashes($filter, '"&') . '"';

Steps to reproduce

$filter = "The 17\" O'Conner && O`Series \n OR a || 1%2 book?";

Expected Behavior

Provide a Helper Class / Function which provides correct escaping for typesense query builder.

$query = 'tags = ' . Helper::escape(addcslashes($filter, '"&'));

Actual Behavior

No documentation or helper method currently provided what need to be escaped and what not.

Metadata

Typesense Version:

OS:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions