Verified Commit 286ab21e authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #3151097 by quietone, nod_, deepakaryan1988, smustgrave, alexpott,...

Issue #3151097 by quietone, nod_, deepakaryan1988, smustgrave, alexpott, tinarey: Replace use of whitelist/blacklist in core/misc/autocomplete.js and LinkWidget.php
parent eeb7175a
Loading
Loading
Loading
Loading
Loading
+19 −4
Original line number Diff line number Diff line
@@ -78,8 +78,8 @@
    }

    const term = autocomplete.extractLastTerm(event.target.value);
    // Abort search if the first character is in firstCharacterBlacklist.
    if (term.length > 0 && options.firstCharacterBlacklist.includes(term[0])) {
    // Abort search if the first character is in firstCharacterDenyList.
    if (term.length > 0 && options.firstCharacterDenyList.includes(term[0])) {
      return false;
    }
    // Only search when the term is at least the minimum length.
@@ -215,8 +215,23 @@
          const blacklist = $autocomplete.attr(
            'data-autocomplete-first-character-blacklist',
          );
          if (blacklist !== undefined) {
            Drupal.deprecationError({
              message:
                'The data-autocomplete-first-character-blocklist attribute is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use firstCharacterDenyList instead. See https://www.drupal.org/node/3472016.',
            });
          }
          const denyList = $autocomplete.attr(
            'data-autocomplete-first-character-denylist',
          );
          Drupal.deprecatedProperty({
            target: autocomplete.options,
            deprecatedProperty: 'firstCharacterBlacklist',
            message:
              'The firstCharacterBlacklist property is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use firstCharacterDenyList instead. See https://www.drupal.org/node/3472016.',
          });
          $.extend(autocomplete.options, {
            firstCharacterBlacklist: blacklist || '',
            firstCharacterDenyList: denyList || blacklist,
          });
          // Use jQuery UI Autocomplete on the textfield.
          $autocomplete.autocomplete(autocomplete.options).each(function () {
@@ -268,7 +283,7 @@
      renderItem,
      minLength: 1,
      // Custom options, used by Drupal.autocomplete.
      firstCharacterBlacklist: '',
      firstCharacterDenyList: '',
      // Custom options, indicate IME usage status.
      isComposing: false,
    },
+1 −1
Original line number Diff line number Diff line
@@ -219,7 +219,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
      //   in https://www.drupal.org/node/2423093.
      $element['uri']['#target_type'] = 'node';
      // Disable autocompletion when the first character is '/', '#' or '?'.
      $element['uri']['#attributes']['data-autocomplete-first-character-blacklist'] = '/#?';
      $element['uri']['#attributes']['data-autocomplete-first-character-denylist'] = '/#?';

      // The link widget is doing its own processing in
      // static::getUriAsDisplayableString().
+1 −1
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ public function blockForm($form, FormStateInterface $form_state): array {
      '#default_value' => $display_uri,
      '#element_validate' => [[static::class, 'validateUriElement']],
      '#attributes' => [
        'data-autocomplete-first-character-blacklist' => '/#?',
        'data-autocomplete-first-character-denylist' => '/#?',
      ],
      // @todo The user should be able to select an entity type. Will be fixed
      //   in https://www.drupal.org/node/2423093.
+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
      '#title' => 'Autocomplete 4',
      '#autocomplete_route_name' => 'form_test.autocomplete_1',
      '#attributes' => [
        'data-autocomplete-first-character-blacklist' => '/',
        'data-autocomplete-first-character-denylist' => '/',
      ],
    ];

+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ module.exports = {
      .waitForElementVisible('body', 1000);

    // Tests that entering a character from the
    // data-autocomplete-first-character-blacklist doesn't start the
    // data-autocomplete-first-character-denylist doesn't start the
    // autocomplete process.
    browser
      .setValue('[name="autocomplete_4"]', '/')