diff options
author | Nathan Kinkade <nkinkade@nkinka.de> | 2010-01-03 15:51:24 +0000 |
---|---|---|
committer | Nathan Kinkade <nkinkade@nkinka.de> | 2010-01-03 15:51:24 +0000 |
commit | 399abbc3a754cf5fdcfdff113446e1bc264091e2 (patch) | |
tree | 592188568e15325d59e51bf19cfdf667fae8d86d /modules/gallery/tests/File_Structure_Test.php | |
parent | 925a6a2220760cb7daacee1ab80a07b61b3a30a1 (diff) | |
parent | 64e5efd57ba1479179c202e1b76b6eeb42d2924c (diff) |
Merge branch 'master' of git://github.com/gallery/gallery3
Diffstat (limited to 'modules/gallery/tests/File_Structure_Test.php')
-rw-r--r-- | modules/gallery/tests/File_Structure_Test.php | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/modules/gallery/tests/File_Structure_Test.php b/modules/gallery/tests/File_Structure_Test.php index 36342fda..b5026188 100644 --- a/modules/gallery/tests/File_Structure_Test.php +++ b/modules/gallery/tests/File_Structure_Test.php @@ -36,6 +36,10 @@ class File_Structure_Test extends Unit_Test_Case { $dir = new GalleryCodeFilterIterator( new RecursiveIteratorIterator(new RecursiveDirectoryIterator(DOCROOT))); foreach ($dir as $file) { + if (strpos($file, "modules/gallery/views/kohana/error.php")) { + continue; + } + if (strpos($file, "views")) { $this->assert_true( preg_match("#/views/.*?(\.html|mrss|txt)\.php$#", $file->getPathname()), @@ -57,10 +61,12 @@ class File_Structure_Test extends Unit_Test_Case { } private function _check_view_preamble($path, &$errors) { + $expected_2 = null; // The preamble for views is a single line that prevents direct script access if (strpos($path, SYSPATH) === 0) { // Kohana preamble $expected = "<?php defined('SYSPATH') OR die('No direct access allowed.'); ?>\n"; + $expected_2 = "<?php defined('SYSPATH') OR die('No direct access allowed.');\n"; // error.php } else { // Gallery preamble // @todo use the same preamble for both! @@ -71,26 +77,32 @@ class File_Structure_Test extends Unit_Test_Case { $actual = fgets($fp); fclose($fp); - if ($expected != $actual) { + if ($expected != $actual && $expected_2 != $actual) { $errors[] = "$path:1\n expected:\n\t$expected\n actual:\n\t$actual"; } } private function _check_php_preamble($path, &$errors) { + $expected_2 = null; $expected_3 = null; $expected_4 = null; if (strpos($path, SYSPATH) === 0 || strpos($path, MODPATH . "unit_test") === 0) { // Kohana: we only care about the first line $fp = fopen($path, "r"); $actual = array(fgets($fp)); fclose($fp); - $expected = array("<?php defined('SYSPATH') OR die('No direct access allowed.');\n"); + $expected = array("<?php defined('SYSPATH') OR die('No direct script access.');\n"); + $expected_2 = array("<?php defined('SYSPATH') OR die('No direct access allowed.');\n"); + $expected_3 = array("<?php defined('SYSPATH') or die('No direct access allowed.');\n"); + $expected_4 = array("<?php defined('SYSPATH') or die('No direct script access.');\n"); } else if (strpos($path, MODPATH . "forge") === 0 || strpos($path, MODPATH . "exif/lib") === 0 || strpos($path, MODPATH . "gallery/lib/HTMLPurifier") === 0 || $path == MODPATH . "user/lib/PasswordHash.php" || $path == DOCROOT . "var/database.php") { // 3rd party module security-only preambles, similar to Gallery's - $expected = array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\");\n"); + $expected = array("<?php defined(\"SYSPATH\") or die(\"No direct access allowed.\");\n"); + $expected_2 = array("<?php defined('SYSPATH') OR die('No direct access allowed.');\n"); + $expected_3 = array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\");\n"); $fp = fopen($path, "r"); $actual = array(fgets($fp)); fclose($fp); @@ -131,7 +143,7 @@ class File_Structure_Test extends Unit_Test_Case { " */", ); } - if ($expected != $actual) { + if ($expected != $actual && $expected_2 != $actual && $expected_3 != $actual && $expected_4 != $actual) { $errors[] = "$path:1\n expected\n\t" . join("\n\t", $expected) . "\n actual:\n\t" . join("\n\t", $actual); } |