in reply to Re^5: DBI do() SQL injection
in thread DBI do() SQL injection

How does dbh quote save the day? What is different from simple quotinq with '' or q or qq ?

Replies are listed 'Best First'.
Re^7: DBI do() SQL injection
by choroba (Cardinal) on Oct 19, 2023 at 18:38 UTC
    #!/usr/bin/perl use warnings; use strict; use feature qw{ say }; use DBI; my $dbh = 'DBI'->connect('dbi:SQLite:dbname=:memory:', "", ""); my $id = q{42', 'Batman'); DROP TABLE customers; -- }; say qq('$id'); say $dbh->quote($id); __END__ Output: '42', 'Batman'); DROP TABLE customers; -- ' '42'', ''Batman''); DROP TABLE customers; -- '

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]