? 972344-7.patch
Index: cdn.fallback.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cdn/cdn.fallback.inc,v
retrieving revision 1.3
diff -u -p -r1.3 cdn.fallback.inc
--- cdn.fallback.inc	15 Oct 2010 08:43:04 -0000	1.3
+++ cdn.fallback.inc	16 Nov 2010 03:42:11 -0000
@@ -39,7 +39,7 @@ function cdn_theme_registry_alter(&$them
  */
 function cdn_preprocess_page(&$variables) {
   global $base_url;
-  $root = preg_quote(base_path()) . '|' . preg_quote($base_url);
+  $root = preg_quote(base_path()) . '|' . preg_quote($base_url . '/');
 
   // CSS
   $pattern = "#href=\"(($root)(.*?\.css)(\?.*)?)\"#";
@@ -51,12 +51,11 @@ function cdn_preprocess_page(&$variables
   _cdn_preprocess_page_helper($variables['closure'], $pattern, 0, 3, 4, 'src="', '"');
 
   // Images
-  $skip_keys = array('styles', 'scripts', 'zebra', 'id', 'directory', 'layout', 'head_title', 'base_path', 'front_page', 'head', 'body_clases');
+  $skip_keys = array('styles', 'scripts', 'zebra', 'id', 'directory', 'layout', 'head_title', 'base_path', 'front_page', 'head', 'body_classes');
   foreach ($variables as $key => $value) {
     if (!in_array($key, $skip_keys) && is_string($value) && !empty($value)) {
-      $matches = array();
-      $pattern = "#(<img\s+|<img\s+[^>]*\s+)src\s*=\s*\"(($root)([^\"]*)(\?.*)?)\"#i";
-      _cdn_preprocess_page_helper($variables[$key], $pattern, 0, 4, 5, '<img src="', '"');
+      $pattern = "#(((<img\s+|<img\s+[^>]*\s+)src\s*=\s*[\"|\'])(($root)([^\"|^\']*)(\?.*)?)([\"|\'](.*?)>))#i";
+      _cdn_preprocess_page_helper($variables[$key], $pattern, 0,6,8,2, '');
     }
   }
 }
@@ -76,7 +75,8 @@ function cdn_preprocess_page(&$variables
  *   The index of (an optional) query string in the array of regexp matches.
  * @param $prefix
  *   $search_index will be replaced by $prefix, plus the altered file URL,
- *   plus the @suffix.
+ *   plus the @suffix. If numeric, then it is assumed to be the index of the
+ *   prefix in the array of regexp matches.
  * @param $suffix
  *   See $prefix.
  */
@@ -91,6 +91,9 @@ function _cdn_preprocess_page_helper(&$h
     $search = $matches[$search_index][$i];
     $path = $matches[$path_index][$i];
 
+    $prefix_string = (is_numeric($prefix)) ? $matches[$prefix][$i] : $prefix;
+    $suffix_string = (is_numeric($suffix)) ? $matches[$suffix][$i] : $suffix;
+
     // Store the current path as the old path, then let cdn_file_url_alter()
     // do its magic by invoking all file_url_alter hooks. When the path hasn't
     // changed and is not already root-relative or protocol-relative, then
@@ -102,7 +105,7 @@ function _cdn_preprocess_page_helper(&$h
     }
 
     $searches[]     = $search;
-    $replacements[] = $prefix . $path . $matches[$querystring_index][$i] . $suffix;
+    $replacements[] = $prefix_string . $path . $matches[$querystring_index][$i] . $suffix_string;
   }
 
   // Apply the generated replacements ton the subject.
