Skip to content

bug: Allow special characters in search #348

@noman-land

Description

@noman-land

Description

When using common characters such as apostrophes (') and others, the search fails and throws a SQL error.

SQLite: near "s": syntax error
Sorry about that. A report has been filed. Please try a different search.

Repro

  1. Open https://transcript.fish
  2. Search "heaven's gate"
  3. See error

Screenshots

Image

Additional info

The actual query gets created here.

const searchEpisodeWordsQuery = (searchTerm: string) => `
  SELECT
    episode
  FROM
    words_fts
  WHERE
    words_fts MATCH '${searchTerm}'
`;

https://github.com/noman-land/transcript.fish/blob/master/src/js/database/queries.ts#L138-L145

It seems this needs to be a prepared statement instead string concat but I couldn't solve this the first time I tried.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is neededsqliteUpdates to sqlite codetypescriptUpdates to Typescript codeuxUpdates to user experience

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions