mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-23 19:22:40 +01:00
Properly handle single-quotes inside of single-quoted text
This commit is contained in:
parent
33a32f29a3
commit
24740da78b
@ -51,10 +51,14 @@ sub execute_module {
|
|||||||
my $module = $self->{pbot}->factoids->factoids->{$keyword}{module};
|
my $module = $self->{pbot}->factoids->factoids->{$keyword}{module};
|
||||||
my $module_dir = $self->{pbot}->module_dir;
|
my $module_dir = $self->{pbot}->module_dir;
|
||||||
|
|
||||||
|
|
||||||
$self->{pbot}->logger->log("(" . (defined $from ? $from : "(undef)") . "): $nick!$user\@$host: Executing module $module $arguments\n");
|
$self->{pbot}->logger->log("(" . (defined $from ? $from : "(undef)") . "): $nick!$user\@$host: Executing module $module $arguments\n");
|
||||||
|
|
||||||
$arguments =~ s/\$nick/$nick/g;
|
$arguments =~ s/\$nick/$nick/g;
|
||||||
|
|
||||||
|
$arguments = quotemeta($arguments);
|
||||||
|
$arguments =~ s/\\\s/ /g;
|
||||||
|
|
||||||
if(exists $self->{pbot}->factoids->factoids->{$keyword}{modulelauncher_subpattern}) {
|
if(exists $self->{pbot}->factoids->factoids->{$keyword}{modulelauncher_subpattern}) {
|
||||||
if($self->{pbot}->factoids->factoids->{$keyword}{modulelauncher_subpattern} =~ m/s\/(.*?)\/(.*)\//) {
|
if($self->{pbot}->factoids->factoids->{$keyword}{modulelauncher_subpattern} =~ m/s\/(.*?)\/(.*)\//) {
|
||||||
my ($p1, $p2) = ($1, $2);
|
my ($p1, $p2) = ($1, $2);
|
||||||
@ -86,30 +90,27 @@ sub execute_module {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my $unquoted_args = $arguments;
|
my $argsbuf = $arguments;
|
||||||
$arguments = "";
|
$arguments = "";
|
||||||
|
|
||||||
while($unquoted_args =~ s/(.*?)('.*)//) {
|
my $lr;
|
||||||
my $prefix = $1;
|
while(1) {
|
||||||
my $remainder = $2;
|
my ($e, $r, $p) = extract_delimited($argsbuf, "'", "[^']+");
|
||||||
|
|
||||||
$arguments .= quotemeta($prefix);
|
if(defined $e) {
|
||||||
|
$e =~ s/\\//g;
|
||||||
my ($e, $r) = extract_delimited($remainder, "'");
|
$e =~ s/'/'\\''/g;
|
||||||
|
$e =~ s/^'\\''/'/;
|
||||||
if(not defined $e) {
|
$e =~ s/'\\''$/'/;
|
||||||
$arguments .= quotemeta($r);
|
$arguments .= $p;
|
||||||
} else {
|
|
||||||
$arguments .= $e;
|
$arguments .= $e;
|
||||||
$unquoted_args = $r;
|
$lr = $r;
|
||||||
|
} else {
|
||||||
|
$arguments .= $lr;
|
||||||
|
last;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$arguments .= $unquoted_args;
|
|
||||||
|
|
||||||
$arguments =~ s/\\\s/ /g;
|
|
||||||
$arguments =~ s/\\-/-/g;
|
|
||||||
|
|
||||||
my $pid = fork;
|
my $pid = fork;
|
||||||
if(not defined $pid) {
|
if(not defined $pid) {
|
||||||
$self->{pbot}->logger->log("Could not fork module: $!\n");
|
$self->{pbot}->logger->log("Could not fork module: $!\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user