From 849b142a70f72790d624fcc68496547790ff0def Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 30 Jan 2021 10:45:47 +0900 Subject: [PATCH 1/3] fix: file path in ViewException message is empty --- system/View/Parser.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/system/View/Parser.php b/system/View/Parser.php index 79501eabb1be..f34dd838c544 100644 --- a/system/View/Parser.php +++ b/system/View/Parser.php @@ -117,13 +117,14 @@ public function render(string $view, array $options = null, bool $saveData = nul if (! is_file($file)) { - $file = $this->loader->locateFile($view, 'Views'); - } + $fileOrig = $file; + $file = $this->loader->locateFile($view, 'Views'); - // locateFile will return an empty string if the file cannot be found. - if (empty($file)) - { - throw ViewException::forInvalidFile($file); + // locateFile will return an empty string if the file cannot be found. + if (empty($file)) + { + throw ViewException::forInvalidFile($fileOrig); + } } if (is_null($this->tempData)) From d30e3b26919443c3464b453f556d5e818666ed1e Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 30 Jan 2021 10:46:37 +0900 Subject: [PATCH 2/3] style: fix indentation --- system/View/Parser.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/View/Parser.php b/system/View/Parser.php index f34dd838c544..7481a9cefee8 100644 --- a/system/View/Parser.php +++ b/system/View/Parser.php @@ -329,8 +329,8 @@ protected function parsePair(string $variable, array $data, string $template): a // Find all matches of space-flexible versions of {tag}{/tag} so we // have something to loop over. preg_match_all( - '#' . $this->leftDelimiter . '\s*' . preg_quote($variable) . '\s*' . $this->rightDelimiter . '(.+?)' . - $this->leftDelimiter . '\s*' . '/' . preg_quote($variable) . '\s*' . $this->rightDelimiter . '#s', $template, $matches, PREG_SET_ORDER + '#' . $this->leftDelimiter . '\s*' . preg_quote($variable) . '\s*' . $this->rightDelimiter . '(.+?)' . + $this->leftDelimiter . '\s*' . '/' . preg_quote($variable) . '\s*' . $this->rightDelimiter . '#s', $template, $matches, PREG_SET_ORDER ); /* From 6db7e1c4f663a426024a0f565891db851193b290 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 30 Jan 2021 10:50:37 +0900 Subject: [PATCH 3/3] test: add test for exception message --- tests/system/View/ParserTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/system/View/ParserTest.php b/tests/system/View/ParserTest.php index 54e9f598bf83..8ef8a84be832 100644 --- a/tests/system/View/ParserTest.php +++ b/tests/system/View/ParserTest.php @@ -942,6 +942,8 @@ public function testRenderFindsView() public function testRenderCannotFindView() { $this->expectException(ViewException::class); + $this->expectExceptionMessageMatches('!/View/Views/Simplest\.php\z!'); + $this->parser->setData(['testString' => 'Hello World']); $this->parser->render('Simplest'); }