diff options
author | David Rothstein <drothstein@gmail.com> | 2013-12-27 15:06:57 -0500 |
---|---|---|
committer | David Rothstein <drothstein@gmail.com> | 2013-12-27 15:06:57 -0500 |
commit | 18d4eaaef88f5397de926f67bf8e6f8d61bb3345 (patch) | |
tree | cb0e8e037951dcdc22c563d26e3a5bfb1a31b25a | |
parent | 1f7dc2774712d9f356a59bb8ccdd4844cc49d6be (diff) | |
download | brdo-18d4eaaef88f5397de926f67bf8e6f8d61bb3345.tar.gz brdo-18d4eaaef88f5397de926f67bf8e6f8d61bb3345.tar.bz2 |
Issue #1955378 by skek, Darren Oh, claudiu.cristea, David_Rothstein: Return same derivative token with path or URI.
-rw-r--r-- | CHANGELOG.txt | 2 | ||||
-rw-r--r-- | modules/image/image.module | 6 | ||||
-rw-r--r-- | modules/image/image.test | 10 |
3 files changed, 17 insertions, 1 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 7302650c1..602d3f9b1 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,6 +1,8 @@ Drupal 7.25, xxxx-xx-xx (development version) ----------------------- +- Fixed a regression in the Image module that made image_style_url() not work + when a relative path (rather than a complete file URI) was passed to it. - Added an optional feature to the Statistics module to allow node views to be tracked by Ajax requests rather than during the server-side generation of the page. This allows the node counter to work on sites that use external page diff --git a/modules/image/image.module b/modules/image/image.module index c9415447b..445e8d0ea 100644 --- a/modules/image/image.module +++ b/modules/image/image.module @@ -1012,10 +1012,14 @@ function image_style_flush($style) { */ function image_style_url($style_name, $path) { $uri = image_style_path($style_name, $path); + + // The passed-in $path variable can be either a relative path or a full URI. + $original_uri = file_uri_scheme($path) ? file_stream_wrapper_uri_normalize($path) : file_build_uri($path); + // The token query is added even if the 'image_allow_insecure_derivatives' // variable is TRUE, so that the emitted links remain valid if it is changed // back to the default FALSE. - $token_query = array(IMAGE_DERIVATIVE_TOKEN => image_style_path_token($style_name, file_stream_wrapper_uri_normalize($path))); + $token_query = array(IMAGE_DERIVATIVE_TOKEN => image_style_path_token($style_name, $original_uri)); // If not using clean URLs, the image derivative callback is only available // with the query string. If the file does not exist, use url() to ensure diff --git a/modules/image/image.test b/modules/image/image.test index 6a8928ac1..4a4aab055 100644 --- a/modules/image/image.test +++ b/modules/image/image.test @@ -221,6 +221,16 @@ class ImageStylesPathAndUrlTestCase extends DrupalWebTestCase { $this->drupalGet(str_replace(IMAGE_DERIVATIVE_TOKEN . '=', 'wrongparam=', $generate_url)); $this->assertResponse(403, 'Image was inaccessible at the URL with a missing token.'); + // Check that the generated URL is the same when we pass in a relative path + // rather than a URI. We need to temporarily switch the default scheme to + // match the desired scheme before testing this, then switch it back to the + // "temporary" scheme used throughout this test afterwards. + variable_set('file_default_scheme', $scheme); + $relative_path = file_uri_target($original_uri); + $generate_url_from_relative_path = image_style_url($this->style_name, $relative_path); + $this->assertEqual($generate_url, $generate_url_from_relative_path, 'Generated URL is the same regardless of whether it came from a relative path or a file URI.'); + variable_set('file_default_scheme', 'temporary'); + // Fetch the URL that generates the file. $this->drupalGet($generate_url); $this->assertResponse(200, 'Image was generated at the URL.'); |