Some code audit fixes and adding some directory separator normalization code to make it work on Windows as well.

This commit is contained in:
Andy Staudacher
2008-11-26 20:21:39 +00:00
parent 25b0dff45c
commit 38e1eef547
2 changed files with 25 additions and 4 deletions

View File

@@ -1,4 +1,23 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2008 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
* @package Core
*

View File

@@ -41,7 +41,8 @@ class File_Structure_Test extends Unit_Test_Case {
}
if (strpos($file, "views")) {
$this->assert_true(
preg_match("#/views/.*?(\.html|mrss)\.php$#", $file->getPathname()),
preg_match("#/views/.*?(\.html|mrss)\.php$#",
strtr($file->getPathname(), DIRECTORY_SEPARATOR, '/')),
"{$file->getPathname()} should end in .html.php or mrss.php");
}
}
@@ -65,7 +66,7 @@ class File_Structure_Test extends Unit_Test_Case {
$expected = $this->_get_preamble(__FILE__);
foreach ($dir as $file) {
if (preg_match("/views/", $file->getPathname())) {
if (preg_match("/views/", strtr($file->getPathname(), DIRECTORY_SEPARATOR, '/'))) {
// The preamble for views is a single line that prevents direct script access
$lines = file($file->getPathname());
$this->assert_equal(
@@ -74,7 +75,7 @@ class File_Structure_Test extends Unit_Test_Case {
"in file: {$file->getPathname()}");
} else if (preg_match("|\.php$|", $file->getPathname())) {
$actual = $this->_get_preamble($file->getPathname());
if ($file->getPathName() == DOCROOT . "index.php") {
if (strtr($file->getPathName(), DIRECTORY_SEPARATOR, '/') == DOCROOT . "index.php") {
// index.php allows direct access, so modify our expectations for the first line
$index_expected = $expected;
$index_expected[0] = "<?php";
@@ -118,6 +119,7 @@ class GalleryCodeFilterIterator extends FilterIterator {
public function accept() {
// Skip anything that we didn't write
$path_name = $this->getInnerIterator()->getPathName();
$path_name = strtr($path_name, DIRECTORY_SEPARATOR, '/');
return !(strpos($path_name, ".svn") ||
substr($path_name, -1, 1) == "~" ||
strpos($path_name, SYSPATH) !== false ||