#1037934: properly quote file_scan_directory() calls.

From: Damien Tournoud <damien@commerceguys.com>


---
 install.inc |    2 +-
 locale.inc  |    4 ++--
 theme.inc   |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git includes/install.inc includes/install.inc
index 3956ff9..9259c45 100644
--- includes/install.inc
+++ includes/install.inc
@@ -1073,7 +1073,7 @@ function st($string, array $args = array(), array $options = array()) {
       // with its name ending in {$install_state['parameters']['locale']}.po
       // This might or might not be the entire filename. It is also possible
       // that multiple files end with the same extension, even if unlikely.
-      $po_files = file_scan_directory('./profiles/' . $install_state['parameters']['profile'] . '/translations', '/'. $install_state['parameters']['locale'] .'\.po$/', array('recurse' => FALSE));
+      $po_files = file_scan_directory('./profiles/' . $install_state['parameters']['profile'] . '/translations', '/' . preg_quote($install_state['parameters']['locale']) . '\.po$/', array('recurse' => FALSE));
       if (count($po_files)) {
         require_once DRUPAL_ROOT . '/includes/locale.inc';
         foreach ($po_files as $po_file) {
diff --git includes/locale.inc includes/locale.inc
index e59e28e..0967d85 100644
--- includes/locale.inc
+++ includes/locale.inc
@@ -1981,7 +1981,7 @@ function locale_batch_by_language($langcode, $finished = NULL, $skip = array())
     // with names ending with $langcode.po. This allows for filenames
     // like node-module.de.po to let translators use small files and
     // be able to import in smaller chunks.
-    $files = array_merge($files, file_scan_directory(dirname($component->filename) . '/translations', '/(^|\.)' . $langcode . '\.po$/', array('recurse' => FALSE)));
+    $files = array_merge($files, file_scan_directory(dirname($component->filename) . '/translations', '/(^|\.)' . preg_quote($langcode) . '\.po$/', array('recurse' => FALSE)));
     $components[] = $component->name;
   }
 
@@ -2014,7 +2014,7 @@ function locale_batch_by_component($components, $finished = '_locale_batch_syste
         // as $langcode.po or with names ending with $langcode.po. This allows
         // for filenames like node-module.de.po to let translators use small
         // files and be able to import in smaller chunks.
-        $files = array_merge($files, file_scan_directory(dirname($component->filename) . '/translations', '/(^|\.)(' . $language_list . ')\.po$/', array('recurse' => FALSE)));
+        $files = array_merge($files, file_scan_directory(dirname($component->filename) . '/translations', '/(^|\.)(' . preg_quote($language_list) . ')\.po$/', array('recurse' => FALSE)));
       }
     }
     return _locale_batch_build($files, $finished);
diff --git includes/theme.inc includes/theme.inc
index 0a82a8a..0fda7c3 100644
--- includes/theme.inc
+++ includes/theme.inc
@@ -1039,7 +1039,7 @@ function drupal_find_theme_templates($cache, $extension, $path) {
   $subtheme_paths = isset($theme_paths[$theme]) ? $theme_paths[$theme] : array();
 
   // Escape the periods in the extension.
-  $regex = '/' . str_replace('.', '\.', $extension) . '$/';
+  $regex = '/' . preg_quote($extension) . '$/';
   // Get a listing of all template files in the path to search.
   $files = drupal_system_listing($regex, $path, 'name', 0);
 
