mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-12-17 02:00:59 +08:00
Remove \, from any DSN part (value or bareword). Document that DSN values must be escaped.
This commit is contained in:
@@ -313,6 +313,20 @@ provide defaults for all DSNs that do not specify the option's corresponding
|
||||
key part. For example, if DSN C<h=host1> and option C<--port=12345> are
|
||||
specified, then the tool automatically adds C<P=12345> to DSN.
|
||||
|
||||
=head2 ESCAPING VALUES
|
||||
|
||||
DSNs are usually specified on the command line, so shell quoting and escaping
|
||||
must be taken into account. Special characters, like asterisk (C<*>), need
|
||||
to be quoted and/or escaped properly to be passed as literal characters in
|
||||
DSN values.
|
||||
|
||||
Since DSN parts are separated by commas, literal commas in DSN values must
|
||||
be escaped with a single backslash (C<\>). And since a backslash is
|
||||
the escape character for most shells, two backslashes are required to pass
|
||||
a literal backslash. For example, if the username is literally C<my,name>,
|
||||
it must be specified as C<my\\,name> on most shells. This applies to DSNs
|
||||
and DSN-related options like C<--user>.
|
||||
|
||||
=head2 KEY PARTS
|
||||
|
||||
Many of the tools add more parts to DSNs for special purposes, and sometimes
|
||||
|
||||
@@ -131,9 +131,9 @@ sub parse {
|
||||
|
||||
# Parse given props
|
||||
foreach my $dsn_part ( split($dsn_sep, $dsn) ) {
|
||||
$dsn_part =~ s/\\,/,/g;
|
||||
if ( my ($prop_key, $prop_val) = $dsn_part =~ m/^(.)=(.*)$/ ) {
|
||||
# Handle the typical DSN parts like h=host, P=3306, etc.
|
||||
$prop_val =~ s/\\,/,/g;
|
||||
$given_props{$prop_key} = $prop_val;
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user