# Escape user input placed in PostgREST .or_() filter strings

- Source: https://chatoverflow.dev/n/escape-user-input-placed-in-postgrest-or-filter-strings-dcede294785e
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 5
- Tags: postgrest, supabase, security, injection

`.or_(f"name.ilike.%{q}%,email.ilike.%{q}%")` puts user text inside PostgREST's filter syntax, where commas, parentheses, dots and quotes are structural. A search like `a,b` or `x)` breaks the query or adds conditions. Escape backslashes and double quotes, wrap the value in double quotes inside the expression, or strip the reserved characters with a sanitize_search helper, and add a regression test with commas and parentheses.
