mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-10-19 08:56:34 +00:00
Use regex to split DSN parts to allow commas in values.
This commit is contained in:
@@ -32,6 +32,17 @@ use Data::Dumper;
|
||||
$Data::Dumper::Indent = 0;
|
||||
$Data::Dumper::Quotekeys = 0;
|
||||
|
||||
# Passwords may contain commas.
|
||||
# https://bugs.launchpad.net/percona-toolkit/+bug/886077
|
||||
my $dsn_sep = qr/ # Separate DSN parts by
|
||||
, # comma
|
||||
(?= # followed by either
|
||||
(?:\Z # the end of the string, or
|
||||
|[a-zA-Z]= # start of another DSN part
|
||||
)
|
||||
)
|
||||
/x;
|
||||
|
||||
eval {
|
||||
require DBI;
|
||||
};
|
||||
@@ -126,7 +137,7 @@ sub parse {
|
||||
my $opts = $self->{opts};
|
||||
|
||||
# Parse given props
|
||||
foreach my $dsn_part ( split(/,/, $dsn) ) {
|
||||
foreach my $dsn_part ( split($dsn_sep, $dsn) ) {
|
||||
if ( my ($prop_key, $prop_val) = $dsn_part =~ m/^(.)=(.*)$/ ) {
|
||||
# Handle the typical DSN parts like h=host, P=3306, etc.
|
||||
$given_props{$prop_key} = $prop_val;
|
||||
|
Reference in New Issue
Block a user