mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-06 16:19:02 -05:00
Don't execute functions in ModConfig directives.
This commit is contained in:
parent
a5f902ec71
commit
f02704524c
@ -40,24 +40,26 @@ our @EXPORT = qw(
|
||||
execute_functions
|
||||
);
|
||||
|
||||
sub get_directives($$) {
|
||||
my ($file, $property) = @_;
|
||||
sub get_directives($$;$) {
|
||||
my ($file, $property, $functions) = @_;
|
||||
$functions //= 1;
|
||||
open(my $fh, $file) or return ();
|
||||
|
||||
my @values;
|
||||
while (<$fh>) {
|
||||
if ($_ =~ /^\/\* \$(\S+): (.+) \*\/$/ || $_ =~ /^\/\/\/ \$(\S+): (.+)/) {
|
||||
next unless $1 eq $property;
|
||||
push @values, execute_functions($file, $1, $2);
|
||||
my $value = $functions ? execute_functions($file, $1, $2) : $2;
|
||||
push @values, $value;
|
||||
}
|
||||
}
|
||||
close $fh;
|
||||
return @values;
|
||||
}
|
||||
|
||||
sub get_directive($$;$) {
|
||||
my ($file, $property, $default) = @_;
|
||||
my @values = get_directives($file, $property);
|
||||
sub get_directive($$;$$) {
|
||||
my ($file, $property, $default, $functions) = @_;
|
||||
my @values = get_directives($file, $property, $functions);
|
||||
|
||||
my $value = join ' ', @values;
|
||||
$value =~ s/^\s+|\s+$//g;
|
||||
@ -70,7 +72,7 @@ sub execute_functions($$$) {
|
||||
# NOTE: we have to use 'our' instead of 'my' here because of a Perl bug.
|
||||
for (our @parameters = (); $line =~ /([a-z_]+)\((?:\s*"([^"]*)(?{push @parameters, $2})"\s*)*\)/; undef @parameters) {
|
||||
my $sub = make::directive->can("__function_$1");
|
||||
print_error "unknown $name directive '$1' in $file!" unless $sub;
|
||||
print_error "unknown $name function '$1' in $file!" unless $sub;
|
||||
|
||||
# Call the subroutine and replace the function.
|
||||
my $result = $sub->($file, @parameters);
|
||||
|
@ -344,7 +344,7 @@ for my $mod (sort keys %todo) {
|
||||
|
||||
say "You can add this module to your config with:";
|
||||
say " <module name=\"$hmod\">";
|
||||
for my $tag (get_directives("$RealDir/src/modules/$mod.cpp", 'ModConfig')) {
|
||||
for my $tag (get_directives("$RealDir/src/modules/$mod.cpp", 'ModConfig', 0)) {
|
||||
say " $tag" if $tag;
|
||||
}
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user