Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a helper function to escape filters correctly #49

Open
alexander-schranz opened this issue Nov 16, 2023 · 1 comment
Open

Add a helper function to escape filters correctly #49

alexander-schranz opened this issue Nov 16, 2023 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@alexander-schranz
Copy link

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:

@AbdullahFaqeir AbdullahFaqeir added enhancement New feature or request good first issue Good for newcomers labels Apr 8, 2024
@niccolox
Copy link

I am struggling with tag handling also

surprisingly difficult unhandled use case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants