laravel-airtable
laravel-airtable copied to clipboard
Bug: AirtableApiClient.php's addFilter() should escape quotes in filter target $value
If I run a basic field search using a string that contains quotes:
Airtable::where('Story', 'He said "no"')->get();
I receive an error:
{
"error": {
"type": "INVALID_FILTER_BY_FORMULA",
"message": "The formula for filtering records is invalid: Invalid formula. Please check your formula text."
}
}
I think this is because addFilter() in AirtableApiClient.php is passing the string value through to Airtable without escaping the quotes, confusing the filter:
$this->filters[] = "{{$column}}{$operation}\"{$value}\"";
[2024-05-20 17:01:29] local.DEBUG: Filters: Array
(
[0] => {Story}="He said "no""
)
If I escape the quotes in my text, it works.
Airtable::where('Story', 'He said \"no\"')->get();
[2024-05-20 17:02:01] local.DEBUG: Filters: Array
(
[0] => {Story}="He said \"no\""
)
(There may be a better way to handle this more broadly in constructing API queries than just escaping quotes, but that's as far as I got.)