Use regex to split DSN parts to allow commas in values.

This commit is contained in:
Daniel Nichter
2012-05-24 10:32:39 -06:00
parent 02c523d809
commit 15146353f9
2 changed files with 66 additions and 2 deletions

View File

@@ -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;