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

Bug: AirtableApiClient.php's addFilter() should escape quotes in filter target $value #82

Open
ChrisHardie opened this issue May 20, 2024 · 0 comments

Comments

@ChrisHardie
Copy link

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant