Projet

Général

Profil

Révision 4019484b

Ajouté par Assos Assos il y a plus de 4 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/honeypot/honeypot.info
6 6

  
7 7
files[] = honeypot.test
8 8

  
9
; Information added by Drupal.org packaging script on 2018-08-09
10
version = "7.x-1.25"
9
; Information added by Drupal.org packaging script on 2019-12-13
10
version = "7.x-1.26"
11 11
core = "7.x"
12 12
project = "honeypot"
13
datestamp = "1533849190"
13
datestamp = "1576274590"
drupal7/sites/all/modules/honeypot/honeypot.install
69 69
  }
70 70

  
71 71
  // Delete 'honeypot' directory from files directory.
72
  drupal_load('module', 'honeypot');
72 73
  file_unmanaged_delete_recursive(honeypot_file_default_scheme() . '://honeypot');
73 74
}
74 75

  
drupal7/sites/all/modules/honeypot/honeypot.module
290 290
  $honeypot_value = $element['#value'];
291 291

  
292 292
  // Make sure it's empty.
293
  if (!empty($honeypot_value)) {
293
  if (!empty($honeypot_value) || $honeypot_value == '0') {
294 294
    _honeypot_log($form_state['values']['form_id'], 'honeypot');
295 295
    form_set_error('', t('There was a problem with your form submission. Please refresh the page and try again.'));
296 296
  }
......
440 440
    }
441 441
    $number = $query->countQuery()->execute()->fetchField();
442 442

  
443
    // Don't add more than 30 days' worth of extra time.
444
    $honeypot_time_limit = (int) min($honeypot_time_limit + exp($number) - 1, 2592000);
443
    // Don't add more time than the expiration window.
444
    $honeypot_time_limit = (int) min($honeypot_time_limit + exp($number) - 1, $expire_time);
445 445
    $additions = module_invoke_all('honeypot_time_limit', $honeypot_time_limit, $form_values, $number);
446 446
    if (count($additions)) {
447 447
      $honeypot_time_limit += array_sum($additions);
drupal7/sites/all/modules/honeypot/honeypot.test
192 192
    $this->assertNoRaw('There was a problem with your form submission. Please wait 6 seconds and try again.');
193 193
    $this->assertFalse($form_errors, 'The were no validation errors when submitting the form.');
194 194
  }
195

  
196
  /**
197
   * Test that any (not-strict-empty) value triggers protection.
198
   */
199
  public function testStrictEmptinessOnHoneypotField() {
200
    // Initialise the form values.
201
    $edit['name'] = $this->randomName();
202
    $edit['mail'] = $edit['name'] . '@example.com';
203

  
204
    // Any value that is not strictly empty should trigger Honeypot.
205
    foreach (['0', ' '] as $value) {
206
      $edit['url'] = $value;
207
      $this->drupalPost('user/register', $edit, t('Create new account'));
208
      $this->assertText(t('There was a problem with your form submission. Please refresh the page and try again.'), "Honeypot protection is triggered when the honeypot field contains '{$value}'.");
209
    }
210
  }
195 211
}
196 212

  
197 213
/**
drupal7/sites/all/modules/honeypot/tests/honeypot_test.info
4 4
package = Testing
5 5
hidden = true
6 6

  
7
; Information added by Drupal.org packaging script on 2018-08-09
8
version = "7.x-1.25"
7
; Information added by Drupal.org packaging script on 2019-12-13
8
version = "7.x-1.26"
9 9
core = "7.x"
10 10
project = "honeypot"
11
datestamp = "1533849190"
11
datestamp = "1576274590"

Formats disponibles : Unified diff