Bug #7856: Allow underscore characters in path
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 30 Jun 2009 18:43:15 +0000 (12:43 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 30 Jun 2009 18:43:15 +0000 (12:43 -0600)
framework/Autoloader/lib/Horde/Autoloader.php
framework/Autoloader/package.xml

index 5be7252..f386b07 100644 (file)
@@ -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;
index 2b7538e..4b9c379 100644 (file)
@@ -5,8 +5,8 @@ http://pear.php.net/dtd/package-2.0
 http://pear.php.net/dtd/package-2.0.xsd">
  <name>Autoloader</name>
  <channel>pear.horde.org</channel>
- <summary>Horde Class Autoloader</summary>
- <description>Autoload implementation and class loading manager for Horde
+ <summary>Horde Autoloader</summary>
+ <description>Autoload implementation and class loading manager for Horde.
  </description>
  <lead>
   <name>Chuck Hagenbuch</name>
@@ -31,7 +31,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
   <api>beta</api>
  </stability>
  <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>Rename to Horde_Autoloader.
+ <notes>* Bug #7856: Allow underscores in pathname.
+ * Rename to Horde_Autoloader.
  </notes>
  <contents>
   <dir name="/">
@@ -48,7 +49,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
     <min>5.2</min>
    </php>
    <pearinstaller>
-    <min>1.5</min>
+    <min>1.5.4</min>
    </pearinstaller>
   </required>
  </dependencies>