瀏覽代碼

[DependencyInjection] added a check for the class name when dumping a container to PHP

Fabien Potencier 15 年之前
父節點
當前提交
ca8762141f
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      src/Symfony/Components/DependencyInjection/Dumper/PhpDumper.php

+ 4 - 0
src/Symfony/Components/DependencyInjection/Dumper/PhpDumper.php

@@ -87,6 +87,10 @@ EOF;
     {
         $class = $this->dumpValue($definition->getClass());
 
+        if (0 === strpos($class, "'") && !preg_match('/^\'[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\'$/', $class)) {
+            throw new \InvalidArgumentException(sprintf('"%s" is not a valid class name.', $class));
+        }
+
         $arguments = array();
         foreach ($definition->getArguments() as $value) {
             $arguments[] = $this->dumpValue($value);