mirror of
https://github.com/pragma-/pbot.git
synced 2025-10-14 15:07:22 +02:00
applets/trans.pl: whitelist allowed options
This commit is contained in:
parent
66ce01a0c3
commit
4582e225e5
27
applets/trans.pl
vendored
27
applets/trans.pl
vendored
@ -5,6 +5,8 @@
|
|||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
|
use Getopt::Long qw/GetOptionsFromString/;
|
||||||
|
|
||||||
if (not @ARGV) {
|
if (not @ARGV) {
|
||||||
print "Usage: trans [options] [source]:[targets] <word or phrase>\n";
|
print "Usage: trans [options] [source]:[targets] <word or phrase>\n";
|
||||||
exit;
|
exit;
|
||||||
@ -17,9 +19,28 @@ $args =~ s/^\s+|\s+$//g;
|
|||||||
my $opts = '-j -no-ansi -no-autocorrect -no-browser -no-pager -no-play';
|
my $opts = '-j -no-ansi -no-autocorrect -no-browser -no-pager -no-play';
|
||||||
$opts .= ' -b' unless $args =~ /^-/;
|
$opts .= ' -b' unless $args =~ /^-/;
|
||||||
|
|
||||||
if ($args =~ m/-(pager|browser|player|download|p|I|interactive|shell|emacs|E|x|4|6|ipv|inet|u|U|upgrade|user)/) {
|
{
|
||||||
print "I don't think so.\n";
|
my $opt_err;
|
||||||
exit;
|
local $SIG{__WARN__} = sub {
|
||||||
|
$opt_err = shift;
|
||||||
|
chomp $opt_err;
|
||||||
|
};
|
||||||
|
|
||||||
|
Getopt::Long::Configure('no_auto_abbrev', 'no_ignore_case');
|
||||||
|
|
||||||
|
my %h;
|
||||||
|
my @allowed = qw/V version H help M man T reference R reference-english S list-engines list-languages list-languages-english list-codes list-all L linguist e engine b brief d dictionary identify show-original show-original-phonetics show-translation show-translation-phonetics show-prompt-message show-languages show-original-dictionary show-dictionary show-alternatives hl host s sl source from t tl target to/;
|
||||||
|
my ($ret, $rest) = GetOptionsFromString($args, \%h, @allowed);
|
||||||
|
|
||||||
|
if ($opt_err) {
|
||||||
|
print "$opt_err\n";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($ret != 1) {
|
||||||
|
print "Error parsing options.\n";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my $result = `trans $opts $args`;
|
my $result = `trans $opts $args`;
|
||||||
|
@ -25,7 +25,7 @@ use PBot::Imports;
|
|||||||
# These are set by the /misc/update_version script
|
# These are set by the /misc/update_version script
|
||||||
use constant {
|
use constant {
|
||||||
BUILD_NAME => "PBot",
|
BUILD_NAME => "PBot",
|
||||||
BUILD_REVISION => 4874,
|
BUILD_REVISION => 4875,
|
||||||
BUILD_DATE => "2025-07-19",
|
BUILD_DATE => "2025-07-19",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user