3
0
mirror of https://github.com/pragma-/pbot.git synced 2025-01-25 19:44:26 +01:00

Fix escaping of pipes and command substitutions

This commit is contained in:
Pragmatic Software 2018-05-21 19:27:57 -07:00
parent 9279c228dd
commit e1028f84a2
2 changed files with 10 additions and 7 deletions

View File

@ -952,6 +952,7 @@ sub handle_action {
$stuff->{no_nickoverride} = 0; $stuff->{no_nickoverride} = 0;
} }
$stuff->{arguments} = ""; $stuff->{arguments} = "";
$stuff->{original_arguments} = "";
} else { } else {
if ($self->{factoids}->hash->{$channel}->{$keyword}->{type} eq 'text') { if ($self->{factoids}->hash->{$channel}->{$keyword}->{type} eq 'text') {
my $target = $self->{pbot}->{nicklist}->is_present_similar($stuff->{from}, $stuff->{arguments}); my $target = $self->{pbot}->{nicklist}->is_present_similar($stuff->{from}, $stuff->{arguments});
@ -974,7 +975,7 @@ sub handle_action {
# Check if it's an alias # Check if it's an alias
if ($action =~ /^\/call\s+(.*)$/) { if ($action =~ /^\/call\s+(.*)$/) {
my $command = $1; my $command = $1;
$command .= " $stuff->{arguments}" if length $stuff->{arguments}; $command .= " $stuff->{original_arguments}" if length $stuff->{original_arguments};
$stuff->{command} = $command; $stuff->{command} = $command;
$stuff->{aliased} = 1; $stuff->{aliased} = 1;

View File

@ -270,9 +270,6 @@ sub interpret {
} }
} }
# unescape any escaped substituted commands
$arguments =~ s/\\&\{/&{/g if defined $arguments;
# parse out a pipe # parse out a pipe
if (defined $arguments && $arguments =~ m/(?<!\\)\|\s*\{\s*[^}]+\}\s*$/) { if (defined $arguments && $arguments =~ m/(?<!\\)\|\s*\{\s*[^}]+\}\s*$/) {
my ($pipe, $rest, $args) = extract_codeblock $arguments, '{}', '(?s).*?(?<!\\\\)\|\s*'; my ($pipe, $rest, $args) = extract_codeblock $arguments, '{}', '(?s).*?(?<!\\\\)\|\s*';
@ -293,9 +290,6 @@ sub interpret {
$stuff->{pipe} = $pipe; $stuff->{pipe} = $pipe;
} }
# unescape any escaped pipes
$arguments =~ s/\\\|\s*\{/| {/g if defined $arguments;
$stuff->{nickoverride} = $stuff->{nick} if defined $stuff->{nickoverride} and lc $stuff->{nickoverride} eq 'me'; $stuff->{nickoverride} = $stuff->{nick} if defined $stuff->{nickoverride} and lc $stuff->{nickoverride} eq 'me';
if ($keyword !~ /^(?:factrem|forget|set|factdel|factadd|add|factfind|find|factshow|show|forget|factdel|factset|factchange|change|msg|tell|cc|eval|u|udict|ud|actiontrigger|urban|perl|ban|mute|spinach|choose|c|lie|l|adminadd|unmute|unban)$/) { if ($keyword !~ /^(?:factrem|forget|set|factdel|factadd|add|factfind|find|factshow|show|forget|factdel|factset|factchange|change|msg|tell|cc|eval|u|udict|ud|actiontrigger|urban|perl|ban|mute|spinach|choose|c|lie|l|adminadd|unmute|unban)$/) {
@ -332,6 +326,14 @@ sub interpret {
} }
$stuff->{keyword} = $keyword; $stuff->{keyword} = $keyword;
$stuff->{original_arguments} = $arguments;
# unescape any escaped substituted commands
$arguments =~ s/\\&\{/&{/g if defined $arguments;
# unescape any escaped pipes
$arguments =~ s/\\\|\s*\{/| {/g if defined $arguments;
$stuff->{arguments} = $arguments; $stuff->{arguments} = $arguments;
return $self->SUPER::execute_all($stuff); return $self->SUPER::execute_all($stuff);