Projet

Général

Profil

Révision 8dc4e7e8

Ajouté par Assos Assos il y a environ 5 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/remote_stream_wrapper/remote_stream_wrapper.image.inc
9 9
  array_shift($args);
10 10
  $target = implode('/', $args);
11 11

  
12
  // Check that the style is defined, the scheme is valid, and the image
13
  // derivative token is valid. (Sites which require image derivatives to be
14
  // generated without a token can set the 'image_allow_insecure_derivatives'
15
  // variable to TRUE to bypass the latter check, but this will increase the
16
  // site's vulnerability to denial-of-service attacks. To prevent this
17
  // variable from leaving the site vulnerable to the most serious attacks, a
18
  // token is always required when a derivative of a derivative is requested.)
19
  $valid = !empty($style) && file_stream_wrapper_valid_scheme($scheme);
20
  if (!variable_get('image_allow_insecure_derivatives', FALSE) || strpos(ltrim($target, '\/'), 'styles/') === 0) {
21
    $valid = $valid && isset($_GET[IMAGE_DERIVATIVE_TOKEN]) && $_GET[IMAGE_DERIVATIVE_TOKEN] === image_style_path_token($style['name'], $scheme . '://' . $target);
22
  }
23
  if (!$valid) {
24
    return MENU_ACCESS_DENIED;
25
  }
26

  
12 27
  $image_uri = $scheme . '://' . $target;
13 28
  $derivative_uri = remote_stream_wrapper_image_style_path($style['name'], $image_uri);
14 29

  
......
22 37
  // Don't start generating the image if the derivative already exists or if
23 38
  // generation is in progress in another thread.
24 39
  $lock_name = 'image_style_deliver:' . $style['name'] . ':' . drupal_hash_base64($image_uri);
25
  if (!is_file($derivative_uri)) {
40
  if (!file_exists($derivative_uri)) {
26 41
    $lock_acquired = lock_acquire($lock_name);
27 42
    if (!$lock_acquired) {
28 43
      // Tell client to retry again in 3 seconds. Currently no browsers are known
......
36 51

  
37 52
  // Try to generate the image, unless another thread just did it while we were
38 53
  // acquiring the lock.
39
  $success = is_file($derivative_uri) || image_style_create_derivative($style, $image_uri, $derivative_uri);
54
  $success = file_exists($derivative_uri) || image_style_create_derivative($style, $image_uri, $derivative_uri);
40 55

  
41 56
  if (!empty($lock_acquired)) {
42 57
    lock_release($lock_name);

Formats disponibles : Unified diff