iansinnott / full-text-tabs-forever

Full text search all your browsing history
MIT License
78 stars 4 forks source link

Quotes not escaped in DB import/export #13

Open future10se opened 1 month ago

future10se commented 1 month ago

I believe there is an issue with DB import when the page has quotes (e.g. code snippets in documentation).

I am unable to pin it down further because of #12, but I'll share what I can here.

With a DB export that just has one page (https://ai.google.dev/gemini-api/docs/api-key), importing generates the following error in the console:

(output edited for brevity)

background.js:4798 
 Failed running INSERT OR IGNORE INTO document ("1", "Get an API key", "https://ai.google.dev/gemini-api/docs/api-key", "To use the Gemini API, you need an API key.
You can create a key with one click in Google AI Studio.", "To use the Gemini API, you need an API key. You can create a key with one click in Google AI Studio.

[Get an API key](https://makersuite.google.com/app/apikey)

## Verify your API key with a curl command

You can use a curl command to verify your setup. You can pass the API key either in the URL:

API_KEY="YOUR_API_KEY"


Or in the `x-goog-api-key` header:

API_KEY="YOUR_API_KEY"


<content removed for brevity>

## Next steps

*   Check out the [API quickstarts](https://ai.google.dev/tutorials) to learn best practices for securing your API key and using it.", "f58f8b3574230d7199936059007c5eeb7e259f19", "null", "ai.google.dev", "1722946863019", "2024-08-06", "readability", "1722946859304", "1722946863019") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); SQLiteError: near "YOUR_API_KEY": syntax error
    at check (background.js:3106:11)
    at Object.prepare_v2 (background.js:2825:7)
    at async TX.statements (background.js:4780:25)

Could not send response SQLiteError: near "YOUR_API_KEY": syntax error
    at check (background.js:3106:11)
    at Object.prepare_v2 (background.js:2825:7)
    at async TX.statements (background.js:4780:25)

Note the error says SQLiteError: near "YOUR_API_KEY": syntax error, suggesting that the quote marks in the page content are being parsed as part of the DB import.

The DB export looks like valid JSON (though I've not validated it matches the expected structure), so the issue might be part of the import side rather than a lack of escaping quotes in the export.

Tested in Firefox, Brave, and Edge.

iansinnott commented 3 weeks ago

Thanks for reporing this @future10se . I ran into a similar bug while working on the next release and it should be resolved in the next version, although i'm not sure it's the same. Hopefully this will be resolved.