Skip to content
Snippets Groups Projects
Commit ec5b4345 authored by catch's avatar catch
Browse files

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

parent 6a0257c2
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -310,21 +310,11 @@ public function transformDimensions(array &$dimensions) { ...@@ -310,21 +310,11 @@ public function transformDimensions(array &$dimensions) {
} }
/** /**
* Generates a token to protect an image style derivative. * {@inheritdoc}
*
* 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) { public function getPathToken($uri) {
// Return the first eight characters. // Return the first 8 characters.
return substr(Crypt::hmacBase64($this->id() . ':' . $uri, drupal_get_private_key() . drupal_get_hash_salt()), 0, 8); return substr(Crypt::hmacBase64($this->id() . ':' . $uri, \Drupal::service('private_key')->get() . drupal_get_hash_salt()), 0, 8);
} }
/** /**
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
namespace Drupal\image; namespace Drupal\image;
use Drupal\Core\Config\Entity\ConfigEntityInterface; use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\image\ImageEffectInterface;
/** /**
* Provides an interface defining an image style entity. * Provides an interface defining an image style entity.
...@@ -70,10 +69,25 @@ public function buildUri($uri); ...@@ -70,10 +69,25 @@ public function buildUri($uri);
* The absolute URL where a style image can be downloaded, suitable for use * 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. * 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); 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. * Flushes cached media for this style.
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment