Skip to content

addslashes() is crashing the backup #12

@codo

Description

@codo

When I try to make a backup the function backupTableData crashes at this line: return "'" . addslashes($value) . "'";
When I change this to return "'" . $value . "'"; the code runs correctly, but this doesn't prevent SQL-injection anymore.

On https://www.php.net/manual/en/function.addslashes.php there is this comment:
The addslashes() is sometimes incorrectly used to try to prevent SQL Injection.

Although the code runs now, it can give issues when trying to restore a database.
F.e. in my country (The Netherlands) we have names which contain an single quote (apostrof), like 's-Hertogenbosch, 's-Gravenhage, etc.

I have also looked at using htmlspecialchars($value) or htmlentities($value), but I dont think this will catch all the possibile UTF-8 characters?

Can you advice anything?

Best regards,
Cor van Dooren

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions