Security update for Core, with self-updated composer
[yaffs-website] / vendor / symfony / config / Resource / DirectoryResource.php
index ebc930c090742ec309c0ee6549e57b77ade76100..07280b4b877f2b4222a6e7f697280bb76c4ac760 100644 (file)
@@ -26,11 +26,17 @@ class DirectoryResource implements SelfCheckingResourceInterface, \Serializable
      *
      * @param string      $resource The file path to the resource
      * @param string|null $pattern  A pattern to restrict monitored files
+     *
+     * @throws \InvalidArgumentException
      */
     public function __construct($resource, $pattern = null)
     {
-        $this->resource = $resource;
+        $this->resource = realpath($resource) ?: (file_exists($resource) ? $resource : false);
         $this->pattern = $pattern;
+
+        if (false === $this->resource || !is_dir($this->resource)) {
+            throw new \InvalidArgumentException(sprintf('The directory "%s" does not exist.', $resource));
+        }
     }
 
     /**
@@ -42,7 +48,7 @@ class DirectoryResource implements SelfCheckingResourceInterface, \Serializable
     }
 
     /**
-     * {@inheritdoc}
+     * @return string The file path to the resource
      */
     public function getResource()
     {