mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 01:29:03 -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
|
execute_functions
|
||||||
);
|
);
|
||||||
|
|
||||||
sub get_directives($$) {
|
sub get_directives($$;$) {
|
||||||
my ($file, $property) = @_;
|
my ($file, $property, $functions) = @_;
|
||||||
|
$functions //= 1;
|
||||||
open(my $fh, $file) or return ();
|
open(my $fh, $file) or return ();
|
||||||
|
|
||||||
my @values;
|
my @values;
|
||||||
while (<$fh>) {
|
while (<$fh>) {
|
||||||
if ($_ =~ /^\/\* \$(\S+): (.+) \*\/$/ || $_ =~ /^\/\/\/ \$(\S+): (.+)/) {
|
if ($_ =~ /^\/\* \$(\S+): (.+) \*\/$/ || $_ =~ /^\/\/\/ \$(\S+): (.+)/) {
|
||||||
next unless $1 eq $property;
|
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;
|
close $fh;
|
||||||
return @values;
|
return @values;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_directive($$;$) {
|
sub get_directive($$;$$) {
|
||||||
my ($file, $property, $default) = @_;
|
my ($file, $property, $default, $functions) = @_;
|
||||||
my @values = get_directives($file, $property);
|
my @values = get_directives($file, $property, $functions);
|
||||||
|
|
||||||
my $value = join ' ', @values;
|
my $value = join ' ', @values;
|
||||||
$value =~ s/^\s+|\s+$//g;
|
$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.
|
# 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) {
|
for (our @parameters = (); $line =~ /([a-z_]+)\((?:\s*"([^"]*)(?{push @parameters, $2})"\s*)*\)/; undef @parameters) {
|
||||||
my $sub = make::directive->can("__function_$1");
|
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.
|
# Call the subroutine and replace the function.
|
||||||
my $result = $sub->($file, @parameters);
|
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 "You can add this module to your config with:";
|
||||||
say " <module name=\"$hmod\">";
|
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;
|
say " $tag" if $tag;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user