Commit ec498202 authored by catch's avatar catch
Browse files

Issue #3264050 by neclimdul, andypost: Fuzzed tag values to...

Issue #3264050 by neclimdul, andypost: Fuzzed tag values to EntityAutocompleteController::handleAutocomplete can cause deprecation warning

(cherry picked from commit 3ddc2e03)
parent 9b3f4102
Loading
Loading
Loading
Loading
+20 −18
Original line number Diff line number Diff line
@@ -79,8 +79,9 @@ public function handleAutocomplete(Request $request, $target_type, $selection_ha
    $matches = [];
    // Get the typed string from the URL, if it exists.
    if ($input = $request->query->get('q')) {
      $typed_string = Tags::explode($input);
      $typed_string = mb_strtolower(array_pop($typed_string));
      $tag_list = Tags::explode($input);
      if (!empty($tag_list)) {
        $typed_string = mb_strtolower(array_pop($tag_list));

        // Selection settings are passed in as a hashed key of a serialized array
        // stored in the key/value store.
@@ -101,6 +102,7 @@ public function handleAutocomplete(Request $request, $target_type, $selection_ha

        $matches = $this->matcher->getMatches($target_type, $selection_handler, $selection_settings, $typed_string);
      }
    }

    return new JsonResponse($matches);
  }
+4 −0
Original line number Diff line number Diff line
@@ -88,6 +88,10 @@ public function testEntityReferenceAutocompletion() {
      'label' => Html::escape($entity_3->name->value),
    ];
    $this->assertSame($target, reset($data), 'Autocomplete returns an entity label containing a comma and a slash.');

    $input = '"l!J>&Tw';
    $data = $this->getAutocompleteResult($input);
    $this->assertSame([], $data, 'Autocomplete of invalid string returns empty result');
  }

  /**