Commit ec5b4345 authored by catch's avatar catch

Issue #2198325 by fietserwin: GetPathToken not in ImageStyleInterface (+2 other minor cleanups).

parent 6a0257c2
......@@ -310,21 +310,11 @@ public function transformDimensions(array &$dimensions) {
}
/**
* Generates a token to protect an image style derivative.
*
* This prevents unauthorized generation of an image style derivative,
* which can be costly both in CPU time and disk space.
*
* @param string $uri
* The URI of the original image of this style.
*
* @return string
* An eight-character token which can be used to protect image style
* derivatives against denial-of-service attacks.
* {@inheritdoc}
*/
public function getPathToken($uri) {
// Return the first eight characters.
return substr(Crypt::hmacBase64($this->id() . ':' . $uri, drupal_get_private_key() . drupal_get_hash_salt()), 0, 8);
// Return the first 8 characters.
return substr(Crypt::hmacBase64($this->id() . ':' . $uri, \Drupal::service('private_key')->get() . drupal_get_hash_salt()), 0, 8);
}
/**
......
......@@ -8,7 +8,6 @@
namespace Drupal\image;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\image\ImageEffectInterface;
/**
* Provides an interface defining an image style entity.
......@@ -70,10 +69,25 @@ public function buildUri($uri);
* The absolute URL where a style image can be downloaded, suitable for use
* in an <img> tag. Requesting the URL will cause the image to be created.
*
* @see \Drupal\image\ImageStyleInterface::deliver()
* @see \Drupal\image\Controller\ImageStyleDownloadController::deliver()
*/
public function buildUrl($path, $clean_urls = NULL);
/**
* Generates a token to protect an image style derivative.
*
* This prevents unauthorized generation of an image style derivative,
* which can be costly both in CPU time and disk space.
*
* @param string $uri
* The URI of the original image of this style.
*
* @return string
* An eight-character token which can be used to protect image style
* derivatives against denial-of-service attacks.
*/
public function getPathToken($uri);
/**
* Flushes cached media for this style.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment