Skip to content

Commit

Permalink
Fix preambles, and fix the File_Structure_Test to be more lenient
Browse files Browse the repository at this point in the history
because of preamble variation in K24.
  • Loading branch information
bharat committed Dec 22, 2009
1 parent e0dc520 commit 9c5df1d
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 33 deletions.
22 changes: 15 additions & 7 deletions application/Bootstrap.php
@@ -1,13 +1,21 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Kohana process control file, loaded by the front controller.
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* $Id: Bootstrap.php 4679 2009-11-10 01:45:52Z isaiah $
* 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.
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007-2009 Kohana Team
* @license http://kohanaphp.com/license
* 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.
*/

// Kohana benchmarks are prefixed to prevent collisions
Expand Down
20 changes: 19 additions & 1 deletion modules/gallery/config/log_file.php
@@ -1,4 +1,22 @@
<?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-2009 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.
*/

/**
* Message logging directory.
Expand Down
16 changes: 12 additions & 4 deletions modules/gallery/tests/File_Structure_Test.php
Expand Up @@ -57,10 +57,12 @@ public function no_windows_line_endings_test() {
}

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!
Expand All @@ -71,26 +73,32 @@ private function _check_view_preamble($path, &$errors) {
$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);
Expand Down Expand Up @@ -131,7 +139,7 @@ private function _check_php_preamble($path, &$errors) {
" */",
);
}
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);
}
Expand Down
42 changes: 22 additions & 20 deletions modules/kohana23_compat/config/pagination.php
@@ -1,25 +1,27 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
<?php defined("SYSPATH") or die("No direct script access.");
/**
* @package Pagination
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* Pagination configuration is defined in groups which allows you to easily switch
* between different pagination settings for different website sections.
* Note: all groups inherit and overwrite the default group.
* 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.
*
* Group Options:
* directory - Views folder in which your pagination style templates reside
* style - Pagination style template (matches view filename)
* uri_segment - URI segment (int or 'label') in which the current page number can be found
* query_string - Alternative to uri_segment: query string key that contains the page number
* items_per_page - Number of items to display per page
* auto_hide - Automatically hides pagination for single pages
* 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.
*/
$config['default'] = array
(
'directory' => 'pagination',
'style' => 'classic',
'uri_segment' => 3,
'query_string' => '',
'items_per_page' => 20,
'auto_hide' => FALSE,
$config["default"] = array(
"directory" => "pagination",
"style" => "classic",
"uri_segment" => 3,
"query_string" => "",
"items_per_page" => 20,
"auto_hide" => FALSE
);
20 changes: 19 additions & 1 deletion modules/kohana23_compat/libraries/Pagination.php
@@ -1,4 +1,22 @@
<?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-2009 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.
*/
/**
* Pagination library.
*
Expand Down

0 comments on commit 9c5df1d

Please sign in to comment.