diff --git a/modules/image/image.module b/modules/image/image.module index bd54a2b..dbc3483 100644 --- a/modules/image/image.module +++ b/modules/image/image.module @@ -289,7 +289,7 @@ function image_flush_caches() { function image_file_download($uri) { $path = file_uri_target($uri); - // Private file access for image style derivatives. + // Private and Temporary file access for image style derivatives. if (strpos($path, 'styles/') === 0) { $args = explode('/', $path); // Discard the first part of the path (styles). @@ -314,7 +314,7 @@ function image_file_download($uri) { 'Content-Length' => $info['file_size'], // By not explicitly setting them here, this uses normal Drupal // Expires, Cache-Control and ETag headers to prevent proxy or - // browser caching of private images. + // browser caching of private and temporary images. ); } } @@ -837,7 +837,7 @@ function image_style_deliver($style, $scheme) { // If using the private scheme, let other modules provide headers and // control access to the file. - if ($scheme == 'private') { + if (in_array($scheme, array('private', 'temporary'))) { if (file_exists($derivative_uri)) { file_download($scheme, file_uri_target($derivative_uri)); } diff --git a/modules/image/image.test b/modules/image/image.test index 3591979..bd055af 100644 --- a/modules/image/image.test +++ b/modules/image/image.test @@ -153,6 +153,13 @@ class ImageStylesPathAndUrlTestCase extends DrupalWebTestCase { } /** + * Test image_style_url() with a file using the "temporary://" scheme. + */ + function testImageStyleUrlAndPathTemporary() { + $this->_testImageStyleUrlAndPath('temporary'); + } + + /** * Test image_style_url() with the "public://" scheme and unclean URLs. */ function testImageStylUrlAndPathPublicUnclean() { @@ -167,6 +174,13 @@ class ImageStylesPathAndUrlTestCase extends DrupalWebTestCase { } /** + * Test image_style_url() with the "temporary://" schema and unclean URLs. + */ + function testImageStyleUrlAndPathTemporaryUnclean() { + $this->_testImageStyleUrlAndPath('temporary', FALSE); + } + + /** * Test image_style_url() with a file URL that has an extra slash in it. */ function testImageStyleUrlExtraSlash() { @@ -249,7 +263,7 @@ class ImageStylesPathAndUrlTestCase extends DrupalWebTestCase { $generated_image_info = image_get_info($generated_uri); $this->assertEqual($this->drupalGetHeader('Content-Type'), $generated_image_info['mime_type'], 'Expected Content-Type was reported.'); $this->assertEqual($this->drupalGetHeader('Content-Length'), $generated_image_info['file_size'], 'Expected Content-Length was reported.'); - if ($scheme == 'private') { + if (in_array($scheme, array('private', 'temporary'))) { $this->assertEqual($this->drupalGetHeader('Expires'), 'Sun, 19 Nov 1978 05:00:00 GMT', 'Expires header was sent.'); $this->assertEqual($this->drupalGetHeader('Cache-Control'), 'no-cache, must-revalidate, post-check=0, pre-check=0', 'Cache-Control header was set to prevent caching.'); $this->assertEqual($this->drupalGetHeader('X-Image-Owned-By'), 'image_module_test', 'Expected custom header has been added.');