You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
first of all, many thanks for your great work on this module.
I recently used Damian Conway's IO::Prompter module to ask the user for a
DB-password to be used later in a call to DBI->connect().
As it turns out, DBI->connect() tests the parameter passed as password (for
being a string, I guess):
Carp::croak('Usage: $class->connect([$dsn [,$user [,$passwd [,\%attr]]]])')
if (ref $old_driver or ($attr and not ref $attr) or ref $pass);
# ^^^^^^^^^
IO::Prompter->prompt() returns an object with lazy evaluation of the user's
input (unless called with the -verbatim option). Therefore
my $dsn = 'whatever';
my $user = 'fritz';
my $passwd = IO::Prompter->prompt();
DBI->connect($dsn, $user, $passwd);
will croak().
This would solve the problem:
use overload;
Carp::croak('Usage: $class->connect([$dsn [,$user [,$passwd [,\%attr]]]])')
if (ref $old_driver or ($attr and not ref $attr) or
(ref $pass and not overload::Method($pass,q{""}));
(as suggested by Damian).
Now, this is not really a very pressing issue, as I can always use the
-verbatim option for IO::Prompter (or force the lazy evaluation before
calling DBI->connect().
But perhaps you might want to use the above patch (overload being a core module
should make this painless for users of DBI).
As you say, it's not a high priority. However, if you want to contribute, I'd consider a patch that only loads the overload module if needed and includes tests.
Sun Sep 21 08:08:26 2014 The RT System itself - Status changed from 'new' to 'open'
Transcribed verbatim from CPAN RT#96763, warts and all.
Fri Jun 27 07:25:39 2014 zaucker [...] oetiker.ch - Ticket created
Subject: Suggestion: allow Object with stringify overloading as passwd in connect()
Date: Fri, 27 Jun 2014 13:25:25 +0200 (CEST)
To: [email protected]
From: Fritz Zaucker [email protected]
Dear DBI-maintainers,
first of all, many thanks for your great work on this module.
I recently used Damian Conway's IO::Prompter module to ask the user for a
DB-password to be used later in a call to DBI->connect().
As it turns out, DBI->connect() tests the parameter passed as password (for
being a string, I guess):
IO::Prompter->prompt() returns an object with lazy evaluation of the user's
input (unless called with the -verbatim option). Therefore
my $dsn = 'whatever';
my $user = 'fritz';
my $passwd = IO::Prompter->prompt();
DBI->connect($dsn, $user, $passwd);
will croak().
This would solve the problem:
Now, this is not really a very pressing issue, as I can always use the
-verbatim option for IO::Prompter (or force the lazy evaluation before
calling DBI->connect().
But perhaps you might want to use the above patch (overload being a core module
should make this painless for users of DBI).
Cheers,
Fritz
--
Oetiker+Partner AG tel: +41 62 775 9903 (direct)
Fritz Zaucker +41 62 775 9900 (switch board)
Aarweg 15 +41 79 675 0630 (mobile)
CH-4600 Olten fax: +41 62 775 9905
Schweiz web: www.oetiker.ch
The text was updated successfully, but these errors were encountered: