ソースを参照

Fix doc block and use a more generic error message.

mark_story 11 年 前
コミット
ce126ed55a
2 ファイル変更5 行追加3 行削除
  1. 3 1
      src/View/View.php
  2. 2 2
      tests/TestCase/View/ViewTest.php

+ 3 - 1
src/View/View.php

@@ -872,6 +872,7 @@ class View {
  * @param string $file The path to the template file.
  * @param string $path Base path that $file should be inside of.
  * @return string The file path
+ * @throws \Cake\Error\Exception
  */
 	protected function _checkFilePath($file, $path) {
 		if (strpos($file, '..') === false) {
@@ -879,7 +880,8 @@ class View {
 		}
 		$absolute = realpath($file);
 		if (strpos($absolute, $path) !== 0) {
-			throw new Error\MissingViewException(array('file' => $file));
+			$msg = sprintf('Cannot use "%s" as a template, it is not within any view template path.', $file);
+			throw new Exception($msg);
 		}
 		return $absolute;
 	}

+ 2 - 2
tests/TestCase/View/ViewTest.php

@@ -517,7 +517,7 @@ class ViewTest extends TestCase {
 /**
  * Test that getViewFileName() protects against malicious directory traversal.
  *
- * @expectedException Cake\View\Error\MissingViewException
+ * @expectedException Cake\Error\Exception
  * @return void
  */
 	public function testGetViewFileNameDirectoryTraversal() {
@@ -616,7 +616,7 @@ class ViewTest extends TestCase {
 /**
  * Test that getLayoutFileName() protects against malicious directory traversal.
  *
- * @expectedException Cake\View\Error\MissingViewException
+ * @expectedException Cake\Error\Exception
  * @return void
  */
 	public function testGetLayoutFileNameDirectoryTraversal() {