 retrieving revision 1.171
 diff -u -F^f -r1.171 file.inc
 --- includes/file.inc	9 Jun 2009 21:33:12 -0000	1.171
-+++ includes/file.inc	22 Jun 2009 22:32:30 -0000
-@@ -79,20 +79,52 @@
++++ includes/file.inc	23 Jun 2009 20:36:46 -0000
+@@ -79,20 +79,62 @@
  /**
   * Create the download path to a file.
   *
+- * @param $path A string containing the path of the file to generate URL for.
+- * @return A string containing a URL that can be used to download the file.
 + * There are two kinds of files:
-+ * - those in the files directory (which is stored in the file_directory_path
-+ *   variable and can be retrieved using file_directory_path()). These are
-+ *   files that have either been uploaded by users or were generated
-+ *   automatically (for example through CSS aggregation).
-+ * - those outside of the files directory, which ship as part of Drupal core
-+ *   or contributed modules.
++ * - "created files", i.e. those in the files directory (which is stored in
++ *   the file_directory_path variable and can be retrieved using
++ *   file_directory_path()). These are files that have either been uploaded by
++ *   users or were generated automatically (for example through CSS
++ *   aggregation).
++ * - "shipped files", i.e. those outside of the files directory, which ship as
++ *   part of Drupal core or contributed modules or themes.
++ * When the custom_file_url_rewrite() function is defined and returns a
++ * rewritten path (and not FALSE), then that rewritten path is used instead of
++ * creating a URL for the file at the given path.
 + *
-  * @param $path A string containing the path of the file to generate URL for.
-  * @return A string containing a URL that can be used to download the file.
++ * @param $path
++ *   A string containing the Drupal path (i.e. path relative to the Drupal
++ *   root directory) of the file to generate the URL for.
++ * @return
++ *   A string containing a URL that can be used to download the file.
   */
  function file_create_url($path) {
 -  // Strip file_directory_path from $path. We only include relative paths in

retrieving revision 1.343
diff -u -F^f -r1.343 form.inc
--- includes/form.inc	20 Jun 2009 15:17:38 -0000	1.343
+++ includes/form.inc	22 Jun 2009 22:32:33 -0000
@@ -2413,7 +2413,7 @@ function theme_image_button($element) {
     (!empty($element['#value']) ? ('value="' . check_plain($element['#value']) . '" ') : '') .
     'id="' . $element['#id'] . '" ' .

+  // the file doesn't match some conditions to be served from a CDN or static
+  // file server, or because the file has not yet been synced to the CDN or
+  // static file server.
+
+  // Shipped files.
+  if (strpos($path, file_directory_path() . '/') !== 0) {
+    return base_path() . $path;
+  }
+  // Created files.
+  else {
+    switch (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)) {
+      case FILE_DOWNLOADS_PUBLIC:
+        return $GLOBALS['base_url'] . '/' . $path;
+      case FILE_DOWNLOADS_PRIVATE:
+        // Strip file_directory_path from $path. Private downloads' URLs are
+        // rewritten to be served relatively to system/files (which is a menu
+        // callback that streams the file) instead of relatively to the file
+        // directory path.
+        $path = trim(substr($path, strlen(file_directory_path())), '/');
+        return url('system/files/' . $path, array('absolute' => TRUE));
+    }
   }
 }
