Skip to content

exporthtml does not parameterize SQL statements #282

@flrgh

Description

@flrgh

I have a contact with the name Firstname "Some Nickname" Lastname, and this is triggering errors in SQL statements:

[Error]: During sqlite3_prepare_v2(): near "Some": syntax error
         -> Query: "SELECT json_object('id', message._id, 'b', message.body, 'f', message.from_recipient_id, 'tr', thread.recipient_id, 'o', (message.type & 0x1F) IN (2,11,21,22,23,24,25,26), 'd', (message.date_received / 1000 - 1404165600), 'p', SUBSTR("Firstname "Some Nickname" Lastname (_id40)/Firstname "Some Nickname" Lastname.html", 1, LENGTH("Firstname "Some Nickname" Lastname (_id40)/Firstname "Some Nickname" Lastname.html") - 5)) AS line, attachment._id AS rowid, -1 AS uniqueid FROM message LEFT JOIN thread ON thread._id IS message.thread_id LEFT JOIN attachment ON attachment.message_id IS message._id AND attachment.content_type = 'text/x-signal-plain' AND attachment.quote = 0 WHERE message._id = ?
[Warning]: Search_idx query failed or no results

I was surprised to see a SQL string escape error in a function with prepare in the name, but then I looked at the source code and saw that it is just string concatenating the query instead of parameterizing it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions