Index: theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.390
diff -u -r1.390 theme.inc
--- theme.inc	8 Oct 2007 14:15:09 -0000	1.390
+++ theme.inc	19 Oct 2007 12:56:25 -0000
@@ -766,10 +766,12 @@
   // templates separately from checking for patterns.
   $files = drupal_system_listing($regex, $path, 'name', 0);
   foreach ($files as $template => $file) {
-    // Chop off the extension. We do it this way because $template will
-    // have one extension chopped off, but there might be more than one,
-    // such as with .tpl.php
-    $template = substr($template, 0, strpos($template, '.'));
+    // Chop off the extension if there is one. We do it this way because
+    // $template will have one extension chopped off, but there might be more
+    // than one, such as with .tpl.php
+    if (strpos($template, '.') !== FALSE) {
+      $template = substr($template, 0, strpos($template, '.'));
+    }
     // Transform - in filenames to _ to match function naming scheme
     // for the purposes of searching.
     $hook = strtr($template, '-', '_');
