From 73744b1e4c54f4389a14dcf69fd5c94081f48de8 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 30 Jun 2009 12:43:15 -0600 Subject: [PATCH] Bug #7856: Allow underscore characters in path --- framework/Autoloader/lib/Horde/Autoloader.php | 12 ++++++++---- framework/Autoloader/package.xml | 9 +++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/framework/Autoloader/lib/Horde/Autoloader.php b/framework/Autoloader/lib/Horde/Autoloader.php index 5be7252bc..f386b0714 100644 --- a/framework/Autoloader/lib/Horde/Autoloader.php +++ b/framework/Autoloader/lib/Horde/Autoloader.php @@ -42,19 +42,23 @@ class Horde_Autoloader list($pattern, $replace) = $classPattern; $file = $class; - if (!is_null($replace)) { - $file = preg_replace($pattern, $replace, $file); + if (!is_null($replace) && + preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE)) { + $file_path = str_replace(array('::', '_'), '/', substr($file, 0, $matches[0][1])) . + $replace . + str_replace(array('::', '_'), '/', substr($file, $matches[0][1] + strlen($matches[0][0]))); + } else { + $file_path = str_replace(array('::', '_'), '/', $file); } if (!is_null($replace) || preg_match($pattern, $file)) { - $file = str_replace(array('::', '_'), '/', $file) . '.php'; $err_mask = E_ALL ^ E_WARNING; if (defined('E_DEPRECATED')) { $err_mask = $err_mask ^ E_DEPRECATED; } $oldErrorReporting = error_reporting($err_mask); /* @TODO H4: Change back to include */ - $included = include_once $file; + $included = include_once $file_path . '.php'; error_reporting($oldErrorReporting); if ($included) { return true; diff --git a/framework/Autoloader/package.xml b/framework/Autoloader/package.xml index 2b7538e91..4b9c37950 100644 --- a/framework/Autoloader/package.xml +++ b/framework/Autoloader/package.xml @@ -5,8 +5,8 @@ http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> Autoloader pear.horde.org - Horde Class Autoloader - Autoload implementation and class loading manager for Horde + Horde Autoloader + Autoload implementation and class loading manager for Horde. Chuck Hagenbuch @@ -31,7 +31,8 @@ http://pear.php.net/dtd/package-2.0.xsd"> beta LGPL - Rename to Horde_Autoloader. + * Bug #7856: Allow underscores in pathname. + * Rename to Horde_Autoloader. @@ -48,7 +49,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> 5.2 - 1.5 + 1.5.4 -- 2.11.0