Updated \TamerLib > tm > addFunction() to validate the function name and check if the function name is reserved

This commit is contained in:
Netkas 2023-06-17 04:24:15 -04:00
parent 21d0075ed5
commit 129c01b96f
No known key found for this signature in database
GPG key ID: 5DAF58535614062B

View file

@ -293,7 +293,6 @@
self::$supervisor->spawnWorker($path, $count, $channel); self::$supervisor->spawnWorker($path, $count, $channel);
} }
var_dump('monitoring');
self::monitor(-1); self::monitor(-1);
} }
@ -586,6 +585,16 @@
throw new RuntimeException(sprintf('Attempting to addFunction() in \'%s\' mode, only workers can preform addFunction().', self::$mode)); throw new RuntimeException(sprintf('Attempting to addFunction() in \'%s\' mode, only workers can preform addFunction().', self::$mode));
} }
if (!preg_match('/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$/', $function))
{
throw new InvalidArgumentException("Invalid function name: $function");
}
if(method_exists(__CLASS__, $function))
{
throw new InvalidArgumentException(sprintf('Attempting to addFunction() with a function name of \'%s\', this is a reserved function name.', $function));
}
self::$function_pointers[$function] = $callback; self::$function_pointers[$function] = $callback;
} }