From 2feede582857fe8dc816170cd707bd76917c5643 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Fri, 25 Oct 2013 15:57:07 +0000 Subject: [PATCH] Avoid adding extra slashes to the INCLUDE_PATH When the include path is written in bootstrap.php, ensure that extra slashes are not accidentally added --- setup/cli/modules/deploy.php | 3 +-- setup/cli/modules/unpack.php | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/setup/cli/modules/deploy.php b/setup/cli/modules/deploy.php index d2526a534..8ba0c0faf 100644 --- a/setup/cli/modules/deploy.php +++ b/setup/cli/modules/deploy.php @@ -50,8 +50,7 @@ class Deployment extends Unpacker { $include = ($upgrade) ? $this->get_include_dir() : ($options['include'] ? $options['include'] : "{$this->destination}/include"); - if (substr($include, -1) !== '/') - $include .= '/'; + $include = rtrim($include, '/').'/'; # Locate the upload folder $root = $this->find_root_folder(); diff --git a/setup/cli/modules/unpack.php b/setup/cli/modules/unpack.php index 29d881997..55fe6ab5a 100644 --- a/setup/cli/modules/unpack.php +++ b/setup/cli/modules/unpack.php @@ -48,6 +48,7 @@ class Unpacker extends Module { # Read the main.inc.php script $bootstrap_php = $this->destination . '/bootstrap.php'; $lines = explode("\n", file_get_contents($bootstrap_php)); + $include_path = preg_replace('://+:', '/', $include_path); # Try and use ROOT_DIR if (strpos($include_path, $this->destination) === 0) $include_path = "ROOT_DIR . '" . @@ -141,11 +142,12 @@ class Unpacker extends Module { // NOTE: that this won't work for crafty folks who have a define or some // variable in the value of their include path - if (!defined('ROOT_DIR')) define('ROOT_DIR', $this->destination . '/'); + if (!defined('ROOT_DIR')) + define('ROOT_DIR', rtrim($this->destination, '/').'/'); foreach ($lines as $line) eval($line); - return INCLUDE_DIR; + return rtrim(INCLUDE_DIR, '/').'/'; } function run($args, $options) { -- GitLab