Fixed plugin name validation

Invalid characters in plugin names are no longer stripped. They always result in a load error.

The behaviour of replacing spaces with underscores is not changed.
This commit is contained in:
SOFe 2018-01-14 18:28:19 +08:00 committed by GitHub
parent 94feecd44b
commit 7f4b5d282e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -66,8 +66,8 @@ class PluginDescription{
* @throws PluginException * @throws PluginException
*/ */
private function loadMap(array $plugin){ private function loadMap(array $plugin){
$this->name = preg_replace("[^A-Za-z0-9 _.-]", "", $plugin["name"]); $this->name = $plugin["name"];
if($this->name === ""){ if(preg_match('/^[A-Za-z0-9 _.-]+$/', $this->name) === 0){
throw new PluginException("Invalid PluginDescription name"); throw new PluginException("Invalid PluginDescription name");
} }
$this->name = str_replace(" ", "_", $this->name); $this->name = str_replace(" ", "_", $this->name);