3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-10-06 03:18:37 +02: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->{arguments} = "";
$stuff->{original_arguments} = "";
} else {
if ($self->{factoids}->hash->{$channel}->{$keyword}->{type} eq 'text') {
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
if ($action =~ /^\/call\s+(.*)$/) {
my $command = $1;
$command .= " $stuff->{arguments}" if length $stuff->{arguments};
$command .= " $stuff->{original_arguments}" if length $stuff->{original_arguments};
$stuff->{command} = $command;
$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
if (defined $arguments && $arguments =~ m/(?<!\\)\|\s*\{\s*[^}]+\}\s*$/) {
my ($pipe, $rest, $args) = extract_codeblock $arguments, '{}', '(?s).*?(?<!\\\\)\|\s*';
@ -293,9 +290,6 @@ sub interpret {
$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';
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->{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;
return $self->SUPER::execute_all($stuff);