diff --git a/src/LogViewer.php b/src/LogViewer.php index e6296e3..53d256f 100644 --- a/src/LogViewer.php +++ b/src/LogViewer.php @@ -74,11 +74,16 @@ class LogViewer public function __construct($basePath, $dir, $file = null) { $this->basePath = rtrim($basePath, '/'); - $this->currentDirectory = rtrim($dir, '/'); - $this->file = $file; + $this->currentDirectory = $this->formatPath(rtrim($dir, '/')); + $this->file = $this->formatPath($file); $this->files = new Filesystem(); } + protected function formatPath($path) + { + return str_replace(['../'], '', $path); + } + /** * Get file path by giving log file name. * @@ -103,7 +108,7 @@ class LogViewer public function setFilename($value) { - $this->filename = $value; + $this->filename = $this->formatPath($value); } /**