# HG changeset patch
# Parent 69da0d67636c68da54bc22735f880652ae51cd03

diff --git a/sites/all/modules/csstidy/csstidy.module b/sites/all/modules/csstidy/csstidy.module
--- a/sites/all/modules/csstidy/csstidy.module
+++ b/sites/all/modules/csstidy/csstidy.module
@@ -60,18 +60,18 @@
     }
     
     // Discover Aggregated CSS and Optimize Using CSSTidy
-    $path_to_files_directory = base_path() . file_directory_path();
-    $pattern = '/<link(.*?)href="' . preg_quote($path_to_files_directory, '/') . '(.*?)"(.*?)\\/>/';
+    $path_to_files_directory = base_path() . file_directory_path(TRUE);
+    $pattern = '/<link(.*?)href="' . preg_quote($path_to_files_directory, '/') . '(.*?)(\?.*)?"(.*?)\\/>/';
     if (preg_match_all($pattern, $styles, $matches) > 0) {
         foreach ($matches[2] as $i => $aggregated_file_name) {
-            $aggregated_file_path = file_directory_path() . $aggregated_file_name;
+            $aggregated_file_path = file_directory_path(TRUE) . $aggregated_file_name;
             $csstidy_file_name = str_replace('.css', '.tidy.css', $aggregated_file_name);
-            $csstidy_file_path = file_directory_path() . $csstidy_file_name;
+            $csstidy_file_path = file_directory_path(TRUE) . $csstidy_file_name;
             
             // Save the processed CSS file if it doesn't exist yet
             if (!file_exists($csstidy_file_path)) {
                 _csstidy_collect(null, TRUE);
-                $contents = file_get_contents(file_directory_path() . $aggregated_file_name);
+                $contents = file_get_contents(file_directory_path(TRUE) . $aggregated_file_name);
                 $contents = str_replace("left:45%;*left:0%;", '', $contents);
                 // Remove Lightbox2 IE hack and reintroduce it later.
                 
@@ -104,7 +104,7 @@
                 }
                 
                 // Save the contents to the new CSS file
-                file_save_data($contents, $csstidy_file_path, FILE_EXISTS_REPLACE);
+                file_save_data($contents, $csstidy_file_path, FILE_EXISTS_REPLACE, TRUE);
             }
             
             // Replace the aggregated file with the processed CSS file.
